Question: 1 3 . 1 3 LAB: Movie show time display import java.util.Scanner; import java.io . FileInputStream; import java.io . IOException; public class LabProgram { public
LAB: Movie show time display import java.util.Scanner;
import java.ioFileInputStream;
import java.ioIOException;
public class LabProgram
public static void mainString args throws IOException
Scanner scnr new Scanner
System.in;
Type your code here.
String fileName scnrnextLine;
FileInputStream fs new FileInputStreamfileName;
Scanner fileScanner new Scannerfs;
String currentTitle ;
String currentRating ;
String showtimes ;
whilefileScannerhasNextLine
String line fileScanner.nextLine;
String parts line.split;
String showtime partstrim;
String title partstrim;
String rating partstrim;
iftitle.equalscurrentTitle
ifcurrentTitle.isEmpty
printMoviecurrentTitle currentRating, showtimes;
currentTitle title.length title.substring : title;
currentRating rating;
showtimes ;
ifshowtimes.isEmpty
showtimes ;
showtimes showtime;
ifcurrentTitle.isEmpty
printMoviecurrentTitle currentRating, showtimes;
fileScanner.close;
scnrclose;
private static void printMovieString title, String rating, String showtimes
System.out.printfs s sn title, rating, showtimes;
Output differs. See highlights below.
Special character legend
Input
movies.csv
Your output
Expected output
:Compare output
Output differs. See highlights below. Special character legend
Input
moviescsv
Your output
Expected output
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 l in each row.
Column displays the movie titles and is left justified with a minimum of characters.
If the movie title has more than characters, output the first characters only.
Column displays the movie ratings and is right justified with a minimum of characters.
Column 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:
: Wonders of the World,G
:Wonders of the World,G
: Journey to Space, PG
: Buffalo Bill And The Indians or Sitting Bull's History Lesson, PG
: Buffalo Bill And The Indians or Sitting Bull's History Lesson, PG
: Buffalo Bill And The Indians or Sitting Bull's History Lesson, PG
: Adventures of Lewis and Clark, PG
: Adventures of Lewis and Clark, PG
: Halloween, R
the output of the program is:
Wonders of the World
G ::
Journey to Space PG:
Buffalo Bill And The Indians or Sitting Bull PG :::
Adventures of Lewis and Clark PG::
Halloween java
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
