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. Hints: Use the fgets() function to read each line of the input text file. Whe

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter7: Developing An Excel Application
Section: Chapter Questions
Problem 1.6CP
icon
Related questions
Question

9.12 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.

Hints: Use the fgets() function to read each line of the input text file. When extracting texts between the commas, copy the texts character-by-character until a comma is reached. A string always ends with a null character ('\0').

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
363324.2450012.qx3zqy7
Transcribed Image Text: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 363324.2450012.qx3zqy7
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Please convert this C code to Java.

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Lists
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
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage