Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

write in c++
Write a program that would allow the user to interact with a part of the IMDB movie database. Each movie has a unique ID, name, release date, and user rating. You're given a file containing this information (see movies.txt in "Additional files" section). The first 4 rows of this file correspond to the first movie, then after an empty line 4 rows contain information about the second movie and so forth. Format of these fields:

  1. ID is an integer
  2. Name is a string that can contain spaces
  3. Release date is a string in yyyy/mm/dd format
  4. Rating is a fractional number

The number of movies is not provided and does not need to be computed. But the file can't contain more than 100 movies.

Then, it should offer the user a menu with the following options:

  1. Display movies sorted by id
  2. Display movies sorted by release date, then rating
  3. Lookup a release date given a name
  4. Lookup a movie by id
  5. Quit the Program

The program should perform the selected operation and then re-display the menu.

For options 1 and 2, display the information about each movie on a single, separate line. First print the header then values that should line up in columns (use setw).

For option 3 output the release date and for option 4 output the results for the found movie.

For options 3 and 4 if the movie is not found display an appropriate message.

Important: In zyBooks your output has to match exactly. So even if your code works but doesn't have the same formatting you'll lose points.

Implementation details

Your program should contain a structure:

Movie. Has 4 fields:

  • id - integer number
  • name - a string
  • releaseDate - a string
  • rating - double

Important: Don't change field names/data types or their order. You'll not be able to pass all tests otherwise.

Aside from main your program should have at least 6 functions.

void readMovies(ifstream& in, Movie movies[], int& size); // in is a file stream to of "movies.txt" file void displayMovies(Movie movies[], int SIZE); void sortByDateRating(Movie movies[], int SIZE); void sortById(Movie movies[], const int SIZE); int linearSearchByName(Movie movies[], int SIZE, string targetName); int binarySearchById(Movie movies[], int SIZE, int targetId);

  1. readMovies. Should read movies into movies array from "in" file stream. Updates size.
  2. displayMovies. Should nicely print movies array (see "Tips" section)
  3. sortByDateRating. Should sort movies by releaseDate (from older to newer) and if the release dates of two movies are the same they should be ordered by rating in descending order.
  4. sortById. Should sort movies by id field in ascending order.
  5. linearSearchByName. Should find an index of a movie by its name using a linear search. If no such movie exist return -1.
  6. binarySearchById. Should find and index of a movie by its id using a binary search. If no such movie exist return -1.

movies.txt
1
Pulp Fiction
1994年10月14日
8.9

2
The Godfather
1972年04月24日
9.2

3
The Dark Knight
2008年07月18日
9.0

4
The Godfather: Part II
1974年12月18日
9.0

6
The Shawshank Redemption
1994年10月14日
9.3

7
Schindler's List
1994年02月04日
8.9

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
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
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education