AVA 8.13 LAB: Movie show time display Write a program that reads movie data from a csv (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the csv file and outputs the contents according to the following requirements: Each row contains the title, rating, and all showtimes of a unique movie. A space is placed before and after each vertical separator (|) in each row. Column 1 displays the movie titles and is left justified with a minimum of 44 characters. If the movie title has more than 44 characters, output the first 44 characters only. Column 2 displays the movie ratings and is right justified with a minimum of 5 characters. Column 3 displays all the showtimes of the same movie, separated by a space. 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,Journey to Space ,PG-13 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: Wonders of the World | G | 16:40 20:00 Journey to Space | PG-13 | 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 This program must use: import java.util.Scanner; import java.io.FileInputStream; import java.io.IOException *I couldn't upload the movies.csv so I included a screenshot of it along with the code I currently have.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

JAVA 8.13 LAB: Movie show time display

 

Write a program that reads movie data from a csv (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the csv file and outputs the contents according to the following requirements:

  • Each row contains the title, rating, and all showtimes of a unique movie.
  • A space is placed before and after each vertical separator (|) in each row.
  • Column 1 displays the movie titles and is left justified with a minimum of 44 characters.
  • If the movie title has more than 44 characters, output the first 44 characters only.
  • Column 2 displays the movie ratings and is right justified with a minimum of 5 characters.
  • Column 3 displays all the showtimes of the same movie, separated by a space.

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,Journey to Space ,PG-13
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:

Wonders of the World                                |         G | 16:40 20:00
Journey to Space                                       | PG-13 | 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
 
This program must use:
import java.util.Scanner;
import java.io.FileInputStream;
import java.io.IOException
 
*I couldn't upload the movies.csv so I included a screenshot of it along with the code I currently have.
1
2
3
4
5
6
7
8
9
B
A
16:40 Wonders of the World
20:00 Wonders of the World
19:00 Journey to Space
PG-13
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
с
G
G
Transcribed Image Text:1 2 3 4 5 6 7 8 9 B A 16:40 Wonders of the World 20:00 Wonders of the World 19:00 Journey to Space PG-13 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 с G G
1 import java.util.Scanner;
2 import
3 import java.io.IOException;
4
5
6
7
8
алдшино 00
9
2
3
4
5
6
7
8
9
1
3
4
5
6
7
8
9
0
1
2
~3 456
6 }
7
public class LabProgram {
public static void main(String[] args) throws IOException {
Scanner scnr = new Scanner(System.in);
}
java.io.FileInputStream;
FileInputStream fileByteStream
Scanner in FS
fileByteStream
inFS =
}
null;
null;
new FileInputStream("movies.csv");
new Scanner (fileByteStream);
String previousName
while (scnr.hasNextLine()) {
=
}
}
else {
=
=
String line
String words[] = line.split(",");
if (previousName.compareTo(words[1]) != 0) {
}
else {
"0";
System.out.print(" + words[0]);
}
=
LabProgram.jav
scnr.nextLine();
11
System.out.println();
previousName =
words[1];
if (words[1].length() > 44) {
words [1]
words [1].substring(0,44);
System.out.printf("%s", words[1]);
System.out.printf("%-44s", words[1]);
System.out.printf("|%5s|", words[2]);
System.out.printf("%s", words[0]);
Transcribed Image Text:1 import java.util.Scanner; 2 import 3 import java.io.IOException; 4 5 6 7 8 алдшино 00 9 2 3 4 5 6 7 8 9 1 3 4 5 6 7 8 9 0 1 2 ~3 456 6 } 7 public class LabProgram { public static void main(String[] args) throws IOException { Scanner scnr = new Scanner(System.in); } java.io.FileInputStream; FileInputStream fileByteStream Scanner in FS fileByteStream inFS = } null; null; new FileInputStream("movies.csv"); new Scanner (fileByteStream); String previousName while (scnr.hasNextLine()) { = } } else { = = String line String words[] = line.split(","); if (previousName.compareTo(words[1]) != 0) { } else { "0"; System.out.print(" + words[0]); } = LabProgram.jav scnr.nextLine(); 11 System.out.println(); previousName = words[1]; if (words[1].length() > 44) { words [1] words [1].substring(0,44); System.out.printf("%s", words[1]); System.out.printf("%-44s", words[1]); System.out.printf("|%5s|", words[2]); System.out.printf("%s", words[0]);
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Operations of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education