I need help to finish this program please: name of customer(string),id number of
ID: 3620194 • Letter: I
Question
I need help to finish this program please:name of customer(string),id number of customer(int),name of video rented by customer(string), return date of the video(string).
Exercise 3: Using the above struct declaration as a guide, show code to set up a struct called customerType which will have fields for a customer's name, the customer's id number (integer), the title of the movie/video rented, and when the video is to be returned. Also declare a variable customer of the type customerType. Insert this code into the two positions indicated by comments in the inlab4.cc program.
Exercise 4: Add code to read values for the variable customer described in exercise 3. This is accomplished by a call to the function getCustomer(). Complete the function getCustomer() so that it will read values for one customer from the indicated input file stream. Include this code in the indicated position of the inlab4.cc program.
Exercise 5 Add code to the inlab4.cc program to define a variable called allCustomers which will store information contained in the inlab4b.dat file for as many as 20 customers as described in Exercise 4.
Exercise 7: Show function header definition and body for a function called printRentalInfo which will receive the allCustomers array defined in Exercise 5, a movie title, and the number of customers and will print out a list of all the names of customers who have rented the video indicated in the movie title sent to the function. Add this code to inlab4.cc at the indicated position.
Exercise 8: Now complete the Movie Rent Video Store program. Insert a function called printCustomer which will receive one struct of type customerType and will print out all information related to this customer (name, id, name of video rented, and return date of video).
________________________________________
#include
#include
#include
#include
using namespace std;
//maximum number of videos owned by the store
const unsigned int MAX_VIDEOS = 100;
//maximum number of customers
const unsigned int MAX_CUSTOMERS = 20;
//Definition of a Video structure
struct Video
{
string movieTitle; //name of movie
unsigned int numberCopies; //number of copies
string videoType; //type of video
};
//Definition of a customerType structure
struct customerType
{
string CustomerName; int CustomerId; string MovieTitle; int ReturnDay; };
set up a struct called customerType which will have fields for a customer's name, the customer's id number (integer), the title of the movie/video rented, and when the video is to be returned. Also declare a variable customer of the type customerType. Insert this code into the two positions indicated by comments in the inlab4.cc program.//Exercise 3 goes here
};
//function prototypes
int menuSelection();
void getVideo (Video&, ifstream&);
void printVideo (Video);
void getCustomer(customerType&, ifstream&);
void printCustomer(customerType);
void printRentalInfo(customerType[], string , int);
bool numberInSet(int x);
int main ()
{
//variables
Video videoInfo; //used to read in video information
Video allVideos[MAX_VIDEOS]; //an array of videos owned by thestore
//set up a struct called customerType which will have fields for a customer's name, the customer's id number (integer), the title of the movie/video rented, and when the video is to be returned. Also declare a variable customer of the type customerType. Insert this code //one customer's check out information
//Add code to the inlab4.cc program to define a variable called allCustomers which will store information contained in the inlab4b.dat file for as many as 20 customers //array of customer check out info
ifstream videoIn; //input stream for video information
ifstream customerIn; //input stream for customer info
int numVideos=0; //how many videos?
int numCustomers=0; //how many customers?
int choice; //user's menu choice
//open the files and check for file failure
videoIn.open ("inlab4.dat");
if (!videoIn)
{
cerr << "inlab4.dat could not be opened!";
exit (0);
}
customerIn.open("inlab4b.dat");
if (!customerIn)
{
cerr << "inlab4b.dat could not be opened!";
exit (0);
}
//input all videos owned by the video store
getVideo(allVideos[numVideos], videoIn);
while (videoIn)
{
numVideos++;
getVideo(allVideos[numVideos], videoIn);
}
//getCustomer(allCustomers[numCustomers], customerIn);
//while (customerIn)
{
//printCustomer(allCustomers[numCustomers]);
numCustomers++;
//getCustomer(allCustomers[numCustomers], customerIn);
}
//get the user's choice from the menu
choice = menuSelection();
//loop until the user decides to quit
while (choice != 0)
{
switch (choice)
{
//print all videos owned by the store
case 1: {
for (int i=0; i< numVideos; i++)
printVideo(allVideos[i]);
break;
}
//print all store customers
/* case 2: {
for (int j=0; j< numCustomers; j++)
printCustomer(allCustomers[j]);
break;
}
//print out a list of rental information by video titles
case 3: {
for (int k=0; k< numVideos; k++)
{
printVideo(allVideos[k]);
printRentalInfo(allCustomers,allVideos[k].movieTitle,numCustomers);
}
break;
} */
};
choice = menuSelection();
}
return 0;
}
//This method prints a menu, gets the user's selection and returns it.
int menuSelection()
{
int choice; //the user's menu selection
//print the menu and make the user enter a valid menu selection
do
{
cout <<" Welcome to Movie Rent Video Store Information";
cout <<" 1----Print out list of all owned videos";
cout <<" 2----Print out list of all customers";
cout <<" 3----Print out list of rental information by video titles";
cout <<" 0----Exit this program";
cout <<" Please enter choice and hit :";
cin >> choice;
}
while (!numberInSet(choice));
return choice;
}
//This function determines whether the argument x is in
//a valid range. If it is, true is returned; otherwise
//return false.
bool numberInSet(int x)
{
if ( x>3 || x< 0)
return false;
else
return true;
}
//This function reads information about a video from the file
//myIn.
void getVideo (Video& oneVideo, ifstream& myIn)
{
char endOfLine; //used to remove the end of line character
//get the video information
getline(myIn, oneVideo.movieTitle);
myIn >> oneVideo.numberCopies;
myIn.get(endOfLine);
getline (myIn, oneVideo.videoType);
}
//Print out the information about a video.
void printVideo (Video oneVideo)
{
cout << " Name of video: " << oneVideo.movieTitle << endl;
cout << "Number of copies: " << oneVideo.numberCopies << endl;
cout << "Video type: " << oneVideo.videoType << endl;
}
//Read information about one customer from myIn.
void getCustomer(customerType& person, ifstream& myIn)
{
getline(myIn, person.CustomerName);
myIn>>person.CustomerId;
getline(myIn, person.VideoRented);
myIn>>person.ReturnDate;
}
}
void printRentalInfo (customerType people[], string title, int numCustomers)
{
//Exercise 7 goes here
for(int i=0;iif(people[i].VideoRented.compare(title)==0)
cout<
}
//This function prints one person's check out information.
void printCustomer(customerType person)
{
//Exercise 8 goes here
cout<<"Name:"<<?xml:namespace prefix = person.CustomerName<<" ID /><<" ID:"
<<<<" Date :"<
}
These are the input files:
inlab4.dat
A Bridge Too Far
10
mystery
The Cat and Mouse
5
comedy
Today is Night
20
adventure
The Movie Factor
19
musical
All the Robots
20
horror
The Sand
5
adventure
My Name is Sue
14
comedy
Why Me?
2
mystery
The Man in White
17
musical
inlab4b.dat
James W. Wilson
1113
A Bridge Too Far
11/19/95
Wanda T. Bear
1114
A Bridge Too Far
11/19/95
Linda W. Smith
1115
The Man in White
11/20/95
Carol M. Brown
1117
All the Robots
11/20/95
Franklin D. Russell
1118
The Man in White
11/21/95
I need help to finish this program please:
name of customer(string),id number of customer(int),name of video rented by customer(string), return date of the video(string).
Exercise 3: Using the above struct declaration as a guide, show code to set up a struct called customerType which will have fields for a customer's name, the customer's id number (integer), the title of the movie/video rented, and when the video is to be returned. Also declare a variable customer of the type customerType. Insert this code into the two positions indicated by comments in the inlab4.cc program.
Exercise 4: Add code to read values for the variable customer described in exercise 3. This is accomplished by a call to the function getCustomer(). Complete the function getCustomer() so that it will read values for one customer from the indicated input file stream. Include this code in the indicated position of the inlab4.cc program.
Exercise 5 Add code to the inlab4.cc program to define a variable called allCustomers which will store information contained in the inlab4b.dat file for as many as 20 customers as described in Exercise 4.
Exercise 7: Show function header definition and body for a function called printRentalInfo which will receive the allCustomers array defined in Exercise 5, a movie title, and the number of customers and will print out a list of all the names of customers who have rented the video indicated in the movie title sent to the function. Add this code to inlab4.cc at the indicated position.
Exercise 8: Now complete the Movie Rent Video Store program. Insert a function called printCustomer which will receive one struct of type customerType and will print out all information related to this customer (name, id, name of video rented, and return date of video).
________________________________________
#include
#include
#include
#include
using namespace std;
//maximum number of videos owned by the store
const unsigned int MAX_VIDEOS = 100;
//maximum number of customers
const unsigned int MAX_CUSTOMERS = 20;
//Definition of a Video structure
struct Video
{
string movieTitle; //name of movie
unsigned int numberCopies; //number of copies
string videoType; //type of video
};
//Definition of a customerType structure
struct customerType
{
string CustomerName; int CustomerId; string MovieTitle; int ReturnDay; };
set up a struct called customerType which will have fields for a customer's name, the customer's id number (integer), the title of the movie/video rented, and when the video is to be returned. Also declare a variable customer of the type customerType. Insert this code into the two positions indicated by comments in the inlab4.cc program.//Exercise 3 goes here
};
//function prototypes
int menuSelection();
void getVideo (Video&, ifstream&);
void printVideo (Video);
void getCustomer(customerType&, ifstream&);
void printCustomer(customerType);
void printRentalInfo(customerType[], string , int);
bool numberInSet(int x);
int main ()
{
//variables
Video videoInfo; //used to read in video information
Video allVideos[MAX_VIDEOS]; //an array of videos owned by thestore
//set up a struct called customerType which will have fields for a customer's name, the customer's id number (integer), the title of the movie/video rented, and when the video is to be returned. Also declare a variable customer of the type customerType. Insert this code //one customer's check out information
//Add code to the inlab4.cc program to define a variable called allCustomers which will store information contained in the inlab4b.dat file for as many as 20 customers //array of customer check out info
ifstream videoIn; //input stream for video information
ifstream customerIn; //input stream for customer info
int numVideos=0; //how many videos?
int numCustomers=0; //how many customers?
int choice; //user's menu choice
//open the files and check for file failure
videoIn.open ("inlab4.dat");
if (!videoIn)
{
cerr << "inlab4.dat could not be opened!";
exit (0);
}
customerIn.open("inlab4b.dat");
if (!customerIn)
{
cerr << "inlab4b.dat could not be opened!";
exit (0);
}
//input all videos owned by the video store
getVideo(allVideos[numVideos], videoIn);
while (videoIn)
{
numVideos++;
getVideo(allVideos[numVideos], videoIn);
}
//getCustomer(allCustomers[numCustomers], customerIn);
//while (customerIn)
{
//printCustomer(allCustomers[numCustomers]);
numCustomers++;
//getCustomer(allCustomers[numCustomers], customerIn);
}
//get the user's choice from the menu
choice = menuSelection();
//loop until the user decides to quit
while (choice != 0)
{
switch (choice)
{
//print all videos owned by the store
case 1: {
for (int i=0; i< numVideos; i++)
printVideo(allVideos[i]);
break;
}
//print all store customers
/* case 2: {
for (int j=0; j< numCustomers; j++)
printCustomer(allCustomers[j]);
break;
}
//print out a list of rental information by video titles
case 3: {
for (int k=0; k< numVideos; k++)
{
printVideo(allVideos[k]);
printRentalInfo(allCustomers,allVideos[k].movieTitle,numCustomers);
}
break;
} */
};
choice = menuSelection();
}
return 0;
}
//This method prints a menu, gets the user's selection and returns it.
int menuSelection()
{
int choice; //the user's menu selection
//print the menu and make the user enter a valid menu selection
do
{
cout <<" Welcome to Movie Rent Video Store Information";
cout <<" 1----Print out list of all owned videos";
cout <<" 2----Print out list of all customers";
cout <<" 3----Print out list of rental information by video titles";
cout <<" 0----Exit this program";
cout <<" Please enter choice and hit :";
cin >> choice;
}
while (!numberInSet(choice));
return choice;
}
//This function determines whether the argument x is in
//a valid range. If it is, true is returned; otherwise
//return false.
bool numberInSet(int x)
{
if ( x>3 || x< 0)
return false;
else
return true;
}
//This function reads information about a video from the file
//myIn.
void getVideo (Video& oneVideo, ifstream& myIn)
{
char endOfLine; //used to remove the end of line character
//get the video information
getline(myIn, oneVideo.movieTitle);
myIn >> oneVideo.numberCopies;
myIn.get(endOfLine);
getline (myIn, oneVideo.videoType);
}
//Print out the information about a video.
void printVideo (Video oneVideo)
{
cout << " Name of video: " << oneVideo.movieTitle << endl;
cout << "Number of copies: " << oneVideo.numberCopies << endl;
cout << "Video type: " << oneVideo.videoType << endl;
}
//Read information about one customer from myIn.
void getCustomer(customerType& person, ifstream& myIn)
{
getline(myIn, person.CustomerName);
myIn>>person.CustomerId;
getline(myIn, person.VideoRented);
myIn>>person.ReturnDate;
}
}
void printRentalInfo (customerType people[], string title, int numCustomers)
{
//Exercise 7 goes here
for(int i=0;iif(people[i].VideoRented.compare(title)==0)
cout<
}
//This function prints one person's check out information.
void printCustomer(customerType person)
{
//Exercise 8 goes here
cout<<"Name:"<<?xml:namespace prefix = person.CustomerName<<" ID /><<" ID:"
<<<<" Date :"<
}
These are the input files:
inlab4.dat
A Bridge Too Far
10
mystery
The Cat and Mouse
5
comedy
Today is Night
20
adventure
The Movie Factor
19
musical
All the Robots
20
horror
The Sand
5
adventure
My Name is Sue
14
comedy
Why Me?
2
mystery
The Man in White
17
musical
inlab4b.dat
James W. Wilson
1113
A Bridge Too Far
11/19/95
Wanda T. Bear
1114
A Bridge Too Far
11/19/95
Linda W. Smith
1115
The Man in White
11/20/95
Carol M. Brown
1117
All the Robots
11/20/95
Franklin D. Russell
1118
The Man in White
11/21/95
Explanation / Answer
Exercise: 3 customerType cstObject; cstObject.CustomerId=562; cstObject.CustomerName="William"; cstObject.VideoRented="EvilDead"; cstObject.ReturnDate="21 Jan-2010"; Exercise: 4 void getCustomer(customerType& person, ifstream& myIn) { char endOfLine; getline(myIn, person.CustomerName); myIn>>person.CustomerId; getline(myIn, person.VideoRented); myIn>>person.ReturnDate; } I hope this will helps You !
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.