Movie Structure File Write 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 (No more than 20 movies) and send the array to a function that will produce a professional report file (MovieReport.txt) which includes all of the information, an average rating of the critics for each movie.
hi. As you not mentioned on which programming language i should write the program. i am writting it in java. Please upvote. it helps me a lot.
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]
Thank you. please upvote.
Get Answers For Free
Most questions answered within 1 hours.