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: ID is an integer Name is a string that can contain spaces Release date is a string in yyyy/mm/dd format 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: Display movies sorted by id Display movies sorted by release date, then rating Lookup a release date given a name Lookup a movie by id 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); readMovies. Should read movies into movies array from "in" file stream. Updates size. displayMovies. Should nicely print movies array (see "Tips" section) 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. sortById. Should sort movies by id field in ascending order. linearSearchByName. Should find an index of a movie by its name using a linear search. If no such movie exist return -1. 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
write in c++
Write a program that would allow the user to interact with a part of the IMDB movie
- ID is an integer
- Name is a string that can contain spaces
- Release date is a string in yyyy/mm/dd format
- 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:
- Display movies sorted by id
- Display movies sorted by release date, then rating
- Lookup a release date given a name
- Lookup a movie by id
- 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);
- readMovies. Should read movies into movies array from "in" file stream. Updates size.
- displayMovies. Should nicely print movies array (see "Tips" section)
- 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.
- sortById. Should sort movies by id field in ascending order.
- linearSearchByName. Should find an index of a movie by its name using a linear search. If no such movie exist return -1.
- 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
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images