Each row of the csv file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive rows. Ex: If the input of the program is: movies.csv and the contents of movies.csv are: 16:40, Wonders of the World,G 20:00, Wonders of the World,G 19:00,End of the Universe, NC-17 12:45,Buffalo Bill And The Indians or Sitting Bull's History Lesson,PG 15:00,Buffalo Bill And The Indians or Sitting Bull's History Lesson, PG 19:30,Buffalo Bill And The Indians or Sitting Bull's History Lesson,PG 10:00,Adventure of Lewis and Clark,PG-13 14:30, Adventure of Lewis and Clark, PG-13 19:00, Halloween, R the output of the program is: G| 16:40 20:00 | NC-17 | 19:00 PG | 12:45 15:00 19:30 | PG-13 | 10:00 14:30 R| 19:00 Wonders of the World End of the Universe Buffalo Bill And The Indians or Sitting Bull | Adventure of Lewis and Clark Halloween 338758 2149958.qx3zay7 LAB 8.13.1: LAB: Movie show time display 0/ 10 АCTIVITY Downloadable files

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I need to write a java program using these requirements. This is the code I have so far, but Im not sure if it's correct.

import java.io.File;
import java.io.FileNotFoundException;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Scanner;

private class Movie {

public static void main(String[] args) {
// Create LinkedList
LinkedList<String> movies = new LinkedList<>();
// Create HashSet
LinkedHashSet<String> moviesTitle = new LinkedHashSet<>();
// read file name from user
Scanner input = new Scanner(System.in);
String fileName = input.next();
try {
// create an object of Scanner
Scanner file = new Scanner(new File(fileName));
// iterate each line in the file
while (file.hasNextLine()) {
String data = file.nextLine();
movies.add(data);
String[] dataArray = data.split(",");
moviesTitle.add(dataArray[1]);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}

// format each line
for (String title : moviesTitle) {
// print title
System.out.printf("%-44s", title);
String time = "";
String ratings = "";
for (String movie : movies) {
String[] dataArray = movie.split(",");
if (title.equals(dataArray[1])) {
time = time + dataArray[0] + ",";
ratings = ratings + dataArray[2] + ",";
}

}
// print ratings
System.out.printf("%-10s", ratings.substring(0, ratings.length() - 1));
// print times
System.out.printf("%-25s", time.substring(0, time.length() - 1));
// print vertical bar
System.out.printf("%s", "|");
System.out.println();
}

}

}

zyBooks My library > CSC 111: Computer Programming I home > 8.13: LAB: Movie show time display
E zyBooks catalog
Hola/EAO.
Adool Shnikkh
Software Update
Close
macOS Mojave Security Update
2021-005 is available and will be instal...
Details
Each row of the csv file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive
rows.
Ex: If the input of the program is:
movies.csv
and the contents of movies.csv are:
16:40,Wonders of the World,G
20:00,Wonders of the World,G
19:00,End of the Universe,NC-17
12:45,Buffalo Bill And The Indians or Sitting Bull's History Lesson,PG
15:00,Buffalo Bill And The Indians or Sitting Bull's History Lesson,PG
19:30,Buffalo Bill And The Indians or Sitting Bull's History Lesson,PG
10:00,Adventure of Lewis and Clark,PG-13
14:30,Adventure of Lewis and Clark,PG-13
19:00,Halloween,R
the output of the program is:
is:
Wonders of the World
|
G | 16:40 20:00
End of the Universe
| NC-17 | 19:00
Buffalo Bill And The Indians or Sitting Bull |
PG | 12:45 15:00 19:30
Adventure of Lewis and Clark
| PG-13 | 10:00 14:30
Нalloween
|
R | 19:00
338758.2149958.qx3zqy7
LAB
8.13.1: LAB: Movie show time display
0/ 10
АCTIVITY
Downloadable files
Transcribed Image Text:zyBooks My library > CSC 111: Computer Programming I home > 8.13: LAB: Movie show time display E zyBooks catalog Hola/EAO. Adool Shnikkh Software Update Close macOS Mojave Security Update 2021-005 is available and will be instal... Details Each row of the csv file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive rows. Ex: If the input of the program is: movies.csv and the contents of movies.csv are: 16:40,Wonders of the World,G 20:00,Wonders of the World,G 19:00,End of the Universe,NC-17 12:45,Buffalo Bill And The Indians or Sitting Bull's History Lesson,PG 15:00,Buffalo Bill And The Indians or Sitting Bull's History Lesson,PG 19:30,Buffalo Bill And The Indians or Sitting Bull's History Lesson,PG 10:00,Adventure of Lewis and Clark,PG-13 14:30,Adventure of Lewis and Clark,PG-13 19:00,Halloween,R the output of the program is: is: Wonders of the World | G | 16:40 20:00 End of the Universe | NC-17 | 19:00 Buffalo Bill And The Indians or Sitting Bull | PG | 12:45 15:00 19:30 Adventure of Lewis and Clark | PG-13 | 10:00 14:30 Нalloween | R | 19:00 338758.2149958.qx3zqy7 LAB 8.13.1: LAB: Movie show time display 0/ 10 АCTIVITY Downloadable files
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY