Question

*URGENT* Written in C csv file name is movies.csv

trr Name: Date: Movie Structure File ite a program that will read in a CSV file with information regarding movies. The file will contain a movie name, MPAA coding (G, PG, PG-13, R), number of minutes, and ratings (1-10) from the three top critics. Your program will read in the data into an array of structures and send the array to a function that will professionally display all of the information, including the average rating of the critics. Wr Show me this program working!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)

MovieClass.java

public class MovieClass {

private String movieName;

private String MPAA_codingNumber;

private String no_Ofminutes;

private String critic1_rating;

private String critic2_rating;

private String critic3_rating;

public String getMovieName() {

return movieName;

}

public void setMovieName(String movieName) {

this.movieName = movieName;

}

public String getMPAA_codingNumber() {

return MPAA_codingNumber;

}

public void setMPAA_codingNumber(String mPAA_codingNumber) {

MPAA_codingNumber = mPAA_codingNumber;

}

public String getNo_Ofminutes() {

return no_Ofminutes;

}

public void setNo_Ofminutes(String no_Ofminutes) {

this.no_Ofminutes = no_Ofminutes;

}

public String getCritic1_rating() {

return critic1_rating;

}

public void setCritic1_rating(String critic1_rating) {

this.critic1_rating = critic1_rating;

}

public String getCritic2_rating() {

return critic2_rating;

}

public void setCritic2_rating(String critic2_rating) {

this.critic2_rating = critic2_rating;

}

public String getCritic3_rating() {

return critic3_rating;

}

public void setCritic3_rating(String critic3_rating) {

this.critic3_rating = critic3_rating;

}

public MovieClass(String movieName, String mPAA_codingNumber,

String no_Ofminutes, String critic1_rating, String critic2_rating,

String critic3_rating) {

super();

this.movieName = movieName;

MPAA_codingNumber = mPAA_codingNumber;

this.no_Ofminutes = no_Ofminutes;

this.critic1_rating = critic1_rating;

this.critic2_rating = critic2_rating;

this.critic3_rating = critic3_rating;

}

@Override

public String toString() {

return "Movie [Name=" + movieName + ", MPAA Number="

+ MPAA_codingNumber + ", No of Minutes=" + no_Ofminutes

+ ", critic1 rating=" + critic1_rating + ", critic2 rating="

+ critic2_rating + ", critic3 rating=" + critic3_rating + "]";

}

}

2) CSVREader.java

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.IOException;

import java.util.ArrayList;

import java.util.List;

public class CSVReader {

public static void DisplayMovies(List<MovieClass> movies){

for(MovieClass m : movies){

System.out.println(m.toString());

}

}

public static void main(String[] args) {

String csvFile = "C:/Users/ADMIN/Desktop/movies.csv";

BufferedReader br = null;

String line = "";

  

List<MovieClass> movieList = new ArrayList<MovieClass>();

try {

br = new BufferedReader(new FileReader(csvFile));

while ((line = br.readLine()) != null) {

// use comma as separator

String[] Movies = line.split(",");

  

MovieClass movieObj = new MovieClass(Movies[0], Movies[1], Movies[2], Movies[3], Movies[4], Movies[5]);

movieList.add(movieObj);

  

}

  

DisplayMovies(movieList);

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

} finally {

if (br != null) {

try {

br.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

}

Output

Movie [Name=A QuitePl, MPAA Number=pg-13, No of Minutes=91 min, critic1 rating= 8 stars, critic2 rating=8 stars, critic3 rating=8 stars]


Movie [Name=Jumanji, MPAA Number=pg-13, No of Minutes=91 min, critic1 rating= 7 stars, critic2 rating=8 stars, critic3 rating=7 stars]


Movie [Name=Get out, MPAA Number=R, No of Minutes=91 min, critic1 rating= 9 stars, critic2 rating=8 stars, critic3 rating=8 stars]

Add a comment
Know the answer?
Add Answer to:
*URGENT* Written in C csv file name is movies.csv trr Name: Date: Movie Structure File ite...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • HELP WITH C++ The following movies have recently come out: 1. Black Panther, PG-13 2. Avengers:...

    HELP WITH C++ The following movies have recently come out: 1. Black Panther, PG-13 2. Avengers: Infinity War, PG-13 3. A Wrinkle In Time, PG 4. Ready Player One, PG-13 5. Red Sparrow, R 6. The Incredibles 2, G To do: 1. Create a Movie class that stores the movie name and the MPAA rating (i.e. R, PG13, etc.). Write appropriate constructors, setters, and getters. 2. In your main function create an array of type Movie that stores the movie...

  • please help with 3,4,5 e for movie. This structure has three data members: a movie name (string), number of minutes in length (integer), and price of a ticket (floating point) typede struct 4. Dec...

    please help with 3,4,5 e for movie. This structure has three data members: a movie name (string), number of minutes in length (integer), and price of a ticket (floating point) typede struct 4. Declare two movie structure variables. Then, assign values to each of the data members for those individual structures s. Display in the array, and then use a loop to display all information about each movie the name of the first movie. For extra credit, create an array...

  • [C++] Outline: The movie data is read from a file into an array of structs and...

    [C++] Outline: The movie data is read from a file into an array of structs and is sorted using the Selection Sort method and the search is done using the Binary Search algorithm with the year of release as key. This assignment upgrades to an array of pointers to the database elements and converts the Selection Sort and Binary search procedure on the database to selection sort and binary search on the array of pointers to the database.   Requirements: Your...

  • BACKGROUND Movie Review sites collect reviews and will often provide some sort of average review to...

    BACKGROUND Movie Review sites collect reviews and will often provide some sort of average review to sort movies by their quality. In this assignment, you will collect a list of movies and then a list of reviews for each movie. You will then take a simple average (total of reviews divided by number of reviews) for each movie and output a sorted list of movies with their average review. Here you are provided the shell of a program and asked...

  • C++ A sample project is provided AverageGrade that is very similar to the MovieRatings project, but...

    C++ A sample project is provided AverageGrade that is very similar to the MovieRatings project, but it only is inputting one string (className) instead of both the movie name and the MPAA rating. Another difference is that the AverageGrade program scores grades A to F with point values from 4.0 to 0.0 (highest to lowest) while the MovieRatings scores the rating from 1 to 5 (lowest to highest). When using the AverageGrade program as a reference, make sure that the...

  • JAVA Write a program that prompts the user to enter a file name, then opens the...

    JAVA Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it. The input files are assumed to be in CSV format. The input files contain a list of integers on each line separated by commas. The program should read each line, sort the numbers and print the comma separated list of integers on the console. Each sorted list of integers from the same line should be printed together...

  • COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see...

    COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see which professor has the highest rating according to student input. You will create a ProfessorRating class consisting of professor Name and three ratings. The three ratings are used to evaluate easiness, helpfulness, and clarity. The value for each rating is in the range of 1 to 5, with 1 being the lowest and 5 being the highest. Your program should contain the following functionalities:...

  • WONT COMPILE ERROR STRAY / TEXT.H AND CPP PROGRAM SAYING NOT DECLARED HAVE A DRIVER WILL...

    WONT COMPILE ERROR STRAY / TEXT.H AND CPP PROGRAM SAYING NOT DECLARED HAVE A DRIVER WILL PASTE AT BOTTOM MOVIES.CPP #include "movies.h" #include "Movie.h" Movies *Movies::createMovies(int max) { //dynamically create a new Movies structure Movies *myMovies = new Movies; myMovies->maxMovies = max; myMovies->numMovies = 0; //dynamically create the array that will hold the movies myMovies->moviesArray = new Movie *[max]; return myMovies; } void Movies::resizeMovieArray() { int max = maxMovies * 2; //increase size by 2 //make an array that is...

  •    moviestruct.cpp #include <iostream> #include <fstream> #include <cstdlib> #include <ostream> #include <fstream> #include <cstdlib> #include <cstring>...

       moviestruct.cpp #include <iostream> #include <fstream> #include <cstdlib> #include <ostream> #include <fstream> #include <cstdlib> #include <cstring> using namespace std; typedef struct{ int id; char title[250]; int year; char rating[6]; int totalCopies; int rentedCopies; }movie; int loadData(ifstream &infile, movie movies[]); void printAll(movie movies[], int count); void printRated(movie movies[], int count); void printTitled(movie movies[], int count); void addMovie(movie movies[],int &count); void returnMovie(movie movies[],int count); void rentMovie(movie movies[],int count); void saveToFile(movie movies[], int count, char *filename); void printMovie(movie &m); int find(movie movies[], int...

  • Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU...

    Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU START: // This homework is built on homework 06. The given program is an updated version of hw06 solution. It begins by displaying a menu to the user // with the add() function from the last homework, as well as some new options: add an actor/actress to a movie, display a list of movies for // an actor/actress, delete all movies, display all movies,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT