Im trying to write a JAVA program that will allow me to input movies.csv and ouput "Wonders of the World | G | 16:40 20:00 End of the Universe | NC-17 | 19:00 Buffalo Bill And The Indians or Sitting...


Im trying to write a JAVA program that will allow me to input movies.csv and ouput "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 Halloween | R | 19:00".


I need help with my code, this is what it looks like now, please let me know how to fix it.


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


public class LabProgram {


public static void main(String[] args) {
// Create LinkedList
LinkedList movies = new LinkedList<>();
// Create HashSet
LinkedHashSet 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("movies.csv"));
// 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("%s", 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("%s", ratings.substring(0, ratings.length() - 1));
// print times
System.out.printf("%s", time.substring(0, time.length() - 1));
// print vertical bar
System.out.println();
}


}


}



Thr first image attatched shows what its supposed to look like and the 2nd image shows what it looks like when I try to run


Chrome<br>File<br>Edit<br>View<br>History<br>Bookmarks<br>Profiles<br>Tab<br>Window Help<br>Sun Oct 24 11:50 AM<br>FSC myF X<br>Bb LEA X<br>ВЫ Lea X<br>ВЫ Рers X<br>Java X<br>B Java X<br>ВЫ Мос Х<br>Bb Nan X<br>My X<br>zy Sec X<br>O holo X<br>You X<br>Ans X<br>C Writ X<br>Writ X<br>T Obje x<br>W Java X<br>Clas X<br>box. X<br>С 1 Pu X<br>Goo X<br>+<br>learn.zybooks.com/zybook/FARMINGDALECSC111MoorningFall2021/chapter/8/section/13?content_resource_id=52981543<br>27 *<br>A<br>Apps<br>Reading List<br>= zyBooks<br>My library > CSC 111: Computer Programming home ><br>8.13: LAB: Movie show time display<br>E zyBooks catalog<br>? Help/FAQ 8 Adeel Sheikh<br>movies.csV<br>LabProgram.java<br>(Your program)<br>Run program<br>Input (from above)<br>Output (shown below)<br>Program output displayed here<br>Wonders of the World | G,G | 16:40 20:00<br>End of the Universe | NC-17 | 19:00<br>Buffalo Bill And The Indians or Sitting Bull's History Lesson | PG,PG,PG | 12:45 15:00 19:30<br>Adventure of Lewis and Clark | PG-13,PG-13 | 10:00 14:30<br>Halloween | R| 19:00<br>Signature of your work<br>What is this?<br>10/23.. S-<br>S--<br>T0 U-<br>..10/24<br>Feedback?<br>20<br>陽國T四@<br>ОСТ<br>PAGES<br>24<br>DeX<br>a 101<br>

Extracted text: Chrome File Edit View History Bookmarks Profiles Tab Window Help Sun Oct 24 11:50 AM FSC myF X Bb LEA X ВЫ Lea X ВЫ Рers X Java X B Java X ВЫ Мос Х Bb Nan X My X zy Sec X O holo X You X Ans X C Writ X Writ X T Obje x W Java X Clas X box. X С 1 Pu X Goo X + learn.zybooks.com/zybook/FARMINGDALECSC111MoorningFall2021/chapter/8/section/13?content_resource_id=52981543 27 * A Apps Reading List = zyBooks My library > CSC 111: Computer Programming home > 8.13: LAB: Movie show time display E zyBooks catalog ? Help/FAQ 8 Adeel Sheikh movies.csV LabProgram.java (Your program) Run program Input (from above) Output (shown below) Program output displayed here Wonders of the World | G,G | 16:40 20:00 End of the Universe | NC-17 | 19:00 Buffalo Bill And The Indians or Sitting Bull's History Lesson | PG,PG,PG | 12:45 15:00 19:30 Adventure of Lewis and Clark | PG-13,PG-13 | 10:00 14:30 Halloween | R| 19:00 Signature of your work What is this? 10/23.. S- S-- T0 U- ..10/24 Feedback? 20 陽國T四@ ОСТ PAGES 24 DeX a 101
Chrome<br>File<br>Edit<br>View<br>History<br>Bookmarks<br>Profiles<br>Tab<br>Window Help<br>Sun Oct 24 11:50 AM<br>FSC myF X<br>Bb LEA X<br>ВЫ Lea X<br>ВЫ Рers X<br>Java X<br>B Java X<br>ВЫ Мос Х<br>Bb Nan X<br>My X<br>zy Sec X<br>O holo X<br>You X<br>Ans X<br>C Writ X<br>Writ X<br>T Obje x<br>W Java X<br>Clas X<br>box. X<br>С 1 Pu X<br>Goo X<br>+<br>learn.zybooks.com/zybook/FARMINGDALECSC111MoorningFall2021/chapter/8/section/13?content_resource_id=52981543<br>27 *<br>A<br>Apps<br>Reading List<br>= zyBooks<br>-<br>Wonders<br>of the World<br>G | 16:40<br>20:00<br>End of the Universe<br>| NC-17 | 19:00<br>Buffalo Bill And The Indians or Sitting Bull |<br>PG | 12:45<br>15:00 19:30<br>Adventure of Lewis and Clark<br>| PG-13 | 10:00<br>14:30<br>Halloween<br>|<br>R | 19:00<br>338758.2149958.qx3zqy7<br>20<br>陽國T四@<br>ОСТ<br>PAGES<br>24<br>DeX<br>A 101<br>Ili<br>

Extracted text: Chrome File Edit View History Bookmarks Profiles Tab Window Help Sun Oct 24 11:50 AM FSC myF X Bb LEA X ВЫ Lea X ВЫ Рers X Java X B Java X ВЫ Мос Х Bb Nan X My X zy Sec X O holo X You X Ans X C Writ X Writ X T Obje x W Java X Clas X box. X С 1 Pu X Goo X + learn.zybooks.com/zybook/FARMINGDALECSC111MoorningFall2021/chapter/8/section/13?content_resource_id=52981543 27 * A Apps Reading List = zyBooks - 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 Halloween | R | 19:00 338758.2149958.qx3zqy7 20 陽國T四@ ОСТ PAGES 24 DeX A 101 Ili
Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here