I need help with this java program to output as described in the image below: (->: Tab: Created with an expression for inserting a tab, such as \t.) & (The return arrow:Newline: Created with an expression for inserting a new line such as \n, endl(C++), and println(Java).) (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 ) 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);          }       }    } }

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter12: Event-driven Gui Programming, Multithreading, And Animation
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

I need help with this java program to output as described in the image below:

(->: Tab: Created with an expression for inserting a tab, such as \t.) & (The return arrow:Newline: Created with an expression for inserting a new line such as \nendl(C++), and println(Java).)

(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

)

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);
         }
      }
   }
}

Input
Your output
Expected output
movies.csv
Wonders of the World
Wonders of the World
1
|
|
Journey to Space
Buffalo Bill And The Indians or Sitting Bull
Buffalo Bill And The Indians or Sitting Bull |
Buffalo Bill And The Indians or Sitting Bull |
Adventures of Lewis and Clark
|
Adventures of Lewis and Clark
Halloween
Wonders of the World
Journey to Space
|
Buffalo Bill And The Indians or Sitting Bull |
Adventures of Lewis and Clark
Halloween
|
|
G | 16:40
G| 20:00
PG-13 | 19:00
PG | 12:45<
PG | 15:00
PG| 19:30
PG-13 | 10:00
PG-13 | 14:30
R 19:00
G | 16:40 20:00
PG-13 | 19:00
PG | 12:45 15:00 19:30
| PG-13 | 10:00 14:30
I
R
19:00
Transcribed Image Text:Input Your output Expected output movies.csv Wonders of the World Wonders of the World 1 | | Journey to Space Buffalo Bill And The Indians or Sitting Bull Buffalo Bill And The Indians or Sitting Bull | Buffalo Bill And The Indians or Sitting Bull | Adventures of Lewis and Clark | Adventures of Lewis and Clark Halloween Wonders of the World Journey to Space | Buffalo Bill And The Indians or Sitting Bull | Adventures of Lewis and Clark Halloween | | G | 16:40 G| 20:00 PG-13 | 19:00 PG | 12:45< PG | 15:00 PG| 19:30 PG-13 | 10:00 PG-13 | 14:30 R 19:00 G | 16:40 20:00 PG-13 | 19:00 PG | 12:45 15:00 19:30 | PG-13 | 10:00 14:30 I R 19:00
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
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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage