catalog.txt 10 Singing in the Rain 1952 0 10 2 20 Star Wars 1977 2 20 7 30 Wonde
ID: 3857212 • Letter: C
Question
catalog.txt
10
Singing in the Rain
1952
0
10
2
20
Star Wars
1977
2
20
7
30
Wonder Woman
2017
3
10
0
40
The Mummy
1999
3
9
3
50
The Shawshank Redemption
1994
4
3
1
60
The Mummy
2017
3
4
0
70
Cars
2006
1
6
0
80
Finding Nemo
2003
1
9
4
CODE SHOULD BE IN C++
The purpose of this assignment is to use arrays, C-strings, functions and structs to build a menu driven program for a movie rental store. Also, you will use file lO to read and write to a text file. See d2l module 3 "Using File IO" for more details on doing file IO What To Code Write a menu-driven program for store personnel to keep track of movies available in a movie rental store. This requires using an array of struct type called Movie. Every element in the array represents one movie The catalog (array of Movie structs) needs to able to hold up to 200 Movie entries However, the actual number of movies is probably much smaller so the program needs to keep track of how many actual movies are in the catalog A Movie struct Each movie has an unique ID number (this can be a string or a number), title, year, movie rating (the acceptable values would be: G, PG, PG13, R, N17, and NONE as a value for a movie that isn't rated), total number of copies and how many copies rented. The title wont be any larger than 250 characters so you can make C-strings of that size. Note that both total number of copies and number of rented copies need to be integers NOTE: although not a requirement, the movie rating can be made into an enum type but you can also just use a C-string as wellExplanation / Answer
I tried my level best
#include <iostream>
#include <string>
using namespace std;
const int SIZE = 50; //Array size.
struct Moviedata
{
char movieTitle[SIZE]; //Movie Title.
char movieDirector[SIZE]; //The director of the movie.
int yearReleased; //The year the movie was released.
int runningTime; //Running time in minutes
};
//Function prototypes
void displayMovie(first);
void displayMovie(second);
int main()
{
Moviedata first = {"The Hangover", "Todd Phillips", 2009, 99};
Moviedata second = {"Transformers", "Michael Bay", 2007, 135};
displayMovie(first);
displayMovie(second);
return 0;
}
void displayMovie(Moviedata &first)
{
string movieTitle,
movieDirector;
int yearReleased, runningTime;
cout << " Here is the data for the first movie. ";
//Display data stored for the first movie.
cout << "Movie Tittle: " << first.movieTitle << endl;
cout << "Director of the movie: " << first.movieDirector << endl;
cout << "The year the movie was released: " << first.yearReleased <<endl;
cout << "The running time of the movie in minutes: " << first.runningTime << endl;
return 0;
}
void displayMovie(Moviedata &second)
{
string movieTitle,
movieDirector;
int yearReleased,
runningTime;
cout << " Here is the data for the second movie. ";
//Display data stored for the second movie.
cout << "Movie Title: " << second.movieTitle << endl;
cout << "Director of the movie: " << second.movieDirector << endl;
cout << "The year the movie was released: " << second.yearReleased << endl;
cout << "The running time of the movie in minutes: " << second.runningTime << endl;
cout << endl;
return 0;
}
struct Moviedata
{
string movieTitle, movieDirector;
int yearReleased, runningTime;
Moviedata(string A, string B, int C, int D)
{
movieTitle = A,
movieDirector = B,
yearReleased = C,
runningTime = D;
}
};
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.