I need help with the Java code so that it can output as shown in the image below: Input is a csv file like this  - (The csv file is :  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,Adventures of Lewis and Clark,PG-13 14:30,Adventures of Lewis and Clark,PG-13 19:00,Halloween,R )   The code the I need help fixing: import java.util.Scanner; import java.io.FileInputStream; import java.io.IOException; public class LabProgram {     public static void main(String[] args) throws IOException {         Scanner scnr = new Scanner(System.in);         // Read the file name from the user         String fileName = scnr.nextLine();         // Open the CSV file         try (Scanner fileScanner = new Scanner(new FileInputStream(fileName))) {             while (fileScanner.hasNextLine()) {                 // Read each line from the CSV file                 String line = fileScanner.nextLine();                 // Split the line into showtime, title, and rating                 String[] movieData = line.split(",");                 // Extract showtime, title, and rating                 String showtime = movieData[0];                 String title = movieData[1].length() > 44 ? movieData[1].substring(0, 44) : movieData[1];                 String rating = movieData[2];                 // Print the formatted output                 System.out.printf("%-44s | %5s | %s%n", title, rating, showtime);             }         }     } }

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

I need help with the Java code so that it can output as shown in the image below:

Input is a csv file like this 

-

(The csv file is : 

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,Adventures of Lewis and Clark,PG-13

14:30,Adventures of Lewis and Clark,PG-13

19:00,Halloween,R

)

 

The code the I need help fixing:

import java.util.Scanner;
import java.io.FileInputStream;
import java.io.IOException;

public class LabProgram {
    public static void main(String[] args) throws IOException {
        Scanner scnr = new Scanner(System.in);

        // Read the file name from the user
        String fileName = scnr.nextLine();

        // Open the CSV file
        try (Scanner fileScanner = new Scanner(new FileInputStream(fileName))) {
            while (fileScanner.hasNextLine()) {
                // Read each line from the CSV file
                String line = fileScanner.nextLine();

                // Split the line into showtime, title, and rating
                String[] movieData = line.split(",");

                // Extract showtime, title, and rating
                String showtime = movieData[0];
                String title = movieData[1].length() > 44 ? movieData[1].substring(0, 44) : movieData[1];
                String rating = movieData[2];

                // Print the formatted output
                System.out.printf("%-44s | %5s | %s%n", title, rating, showtime);
            }
        }
    }
}

Wonders of the World
Journey to Space
Investigating the Shockingly Big World of Am
Buffalo Bill And The Indians or Sitting Bull |
Adventures of Lewis and Clark
Halloween
G | 16:40 20:00 22:15
| 19:00
PG-13
G
PG
PG-13
R
19:30 22:15
10:30 12:45 15:00
| 10:00 14:30
19:00 21:00
Transcribed Image Text:Wonders of the World Journey to Space Investigating the Shockingly Big World of Am Buffalo Bill And The Indians or Sitting Bull | Adventures of Lewis and Clark Halloween G | 16:40 20:00 22:15 | 19:00 PG-13 G PG PG-13 R 19:30 22:15 10:30 12:45 15:00 | 10:00 14:30 19:00 21:00
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
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