You have been asked to help prototype a “movie-rental-system” that manages the r
ID: 3787530 • Letter: Y
Question
You have been asked to help prototype a “movie-rental-system” that manages the rental and returns for 10 movies and 8 customers as a prototype. Assume that each customer can only rent one movie at a time; the rented movie must be returned before another rental can be made. A user of the program will be presented with a menu of four options:
1. Status.
2. Return Movie.
3. Rent Movie.
4. Exit.
If option 1 (Status) is selected, the program will first print the customers names and the movie rented by them (if any). It will then print the catalog movies available for checkout (i.e. only the movies that are not currently rented by another user).
If option 2 (Return Movie) is selected, the program will print the list of registered customers and ask the user to select their number . For simplicity, assume that the registered customers are fixed to be the TAs and Instructors of CIE. The user can enter the number (1-8) to select the customer number. Once the customer is selected the movie is returned to the store and will be made available to rent by another customer.
1. Kyle Anderson
2. Kyle Christensen
3. Bradley Evans
4. Mathews Jacob
5. Hans Johnson
6. Elaine Mou
7. Brian Schweer
8. Richard Su
If option 3 (Rent Movie) is selected, the program will ask the user to identify the customer from the list of registered customers. The user can enter the number (1-8) to select. If the customer already has a rental, the system prints out a message that the movie should be returned before the new rental can occur. Otherwise the system will present the list of available movies to rent and ask the user to select one of them. The usr can enter the number (1-12) to select the movie. The system marks the movie to be rented to the customer and removes it from the available list of rentals and returns to the main menu.
1. Passengers
2. La La Land
3. Sing
4. Suicide Squad
5. The Girl on the Train
6. The Magnificient Seven
7. Fifty Shades Darker
8. Moana
9. Arrival
Explanation / Answer
//return programme is in c++ and its for 8 customer and 10 movies;
#include<iostream>
#include<string>
using namespace std;
void menu()
{
cout<<" 1. Status. 2. Return movie. 3. Rent Movie. 4. Exit. ";
}
int main()
{
string cust[]={"Kyle Anderson","Kyle Christensen","Bradley Evans","Mathews Jacob","Hans Johnson","Elaine Mou",
"Brian Schweer","Richard Su"};
string movie[]={"Passengers","La La Land","Sing","Suicide Squad","The Girl on the Train","The Magnificient Seven",
"Fifty Shades Darker","Moana","Arrival","abc"};
int num;
int status_cust[8];
int status_movie[10];
for(int i=0;i<8;i++)
status_cust[i]=-1;
for(int i=0;i<10;i++)
status_movie[i]=-1;
while(1){
menu();
cout<<" Enter a number(1-4): ";
cin>>num;
if(num==1)
{
for(int i=0;i<8;i++)
{
cout<<i+1<<". "<<cust[i];
if(status_cust[i]!=-1)
{
cout<<" Rented Movie: "<<movie[status_cust[i]];
}
else
{
cout<<" : No mvoie Rented";
}
cout<<" ";
}
cout<<" Available movie ";
int xx=0;
for(int i=0;i<10;i++)
{ if(status_movie[i]==-1)
{cout<<movie[i]<<" ";
xx=1;
}
}
if(xx==0)
{
cout<<" No Movie Available ";
}
}
else if(num==2)
{
for(int i=0;i<8;i++)
{
cout<<i+1<<". "<<cust[i]<<" ";
}
int num1;
cout<<"Enter a number (1-8): ";
cin>>num1;
num1-=1;
status_movie[status_cust[num1]]=-1;
status_cust[num1]=-1;
}
else if(num==3)
{
for(int i=0;i<8;i++)
{
cout<<i+1<<". "<<cust[i]<<" ";
}
int num1,num2;
int flag=0;
cout<<"Enter a number(1-8): ";
cin>>num1;
num1-=1;
if(status_cust[num1]!=-1)
{ flag=1;
cout<<movie[status_cust[num1]]<<" movie should be returned first ";
}
else
{ cout<<" avilable movie are ";
for(int i=0;i<10;i++)
{
if(status_movie[i]=-1)
{
cout<<" "<<movie[i];
}
}
cout<<" Enter a number(1-10) ";
cin>>num2;
}
if(flag==0){
num2=num2-1;
cout<<" "<<movie[num2]<<" rented to "<<cust[num1]<<" ";
status_cust[num1]=num2;
status_movie[num2]=1;}
}
else
return 0;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.