Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You will add to a menu - based program for the Sakila database. The starter file contains code for running a query to view customer
You will add to a menubased program for the Sakila database. The starter file contains code for running a query to view customer rental information using prepared statements. Add to the main.cpp the code to connect to the database file. You should fill in the viewCustomer function which will be run when the user chooses option This function should run a query that gets the customer information for all customers in the database and uses that to display a menu of options containing the id last name, first name to the user. Based on the user choice the function should print the customer's name, phone number, and address including city, email address, if they are active, and last update for the record. You should use prepared statements to run the queries.
INPUT VALIDATION: You should make sure whenever a user makes a choice from a menu that it is a valid menu option. When choosing a customer from the menu, if the user chooses something outside of the range of valid customers then you should print an error. You also have to handle input failure by adding a cin condtion to your input validation loop, and making sure that you do cin.clear and cin.ignore when you have cin so that you can clean up any input stream problems.
Sample Output:
Welcome to Sakila
Please choose an option enter to quit:
View the rentals for a customer
View Customer Information
Enter Choice:
There are rows in the result. How many do you want to see per page?
Please choose the customer you want to see rentals for enter to go to the next page:
MARY SMITH
PATRICIA JOHNSON
LINDA WILLIAMS
BARBARA JONES
ELIZABETH BROWN
JENNIFER DAVIS
MARIA MILLER
SUSAN WILSON
MARGARET MOORE
DOROTHY TAYLOR
Please choose the customer you want to see rentals for enter to go to the next page or to go to the previous page:
LISA ANDERSON
NANCY THOMAS
KAREN JACKSON
BETTY WHITE
HELEN HARRIS
SANDRA MARTIN
DONNA THOMPSON
CAROL GARCIA
RUTH MARTINEZ
SHARON ROBINSON
There are rows in the result. How many do you want to see per page?
Please choose the rental you want to see enter to go to the next page:
::
::
::
::
::
::
::
::
::
::
Rental Date: ::
Staff: Jon Stephens
Customer: HELEN HARRIS
Film Information:
GROUNDHOG UNCUT A Brilliant Panorama of a Astronaut And a Technical Writer who must Discover a Butler in A Manhattan Penthouse $
Return Date: ::
Please choose an option enter to quit:
View the rentals for a customer
View Customer Information
Enter Choice:
Please choose the customer you want to see:
There are rows in the result. How many do you want to see per page?
Please choose the customer you want to see rentals for enter to go to the next page:
SMITH MARY
JOHNSON PATRICIA
WILLIAMS LINDA
JONES BARBARA
BROWN ELIZABETH
DAVIS JENNIFER
MILLER MARIA
WILSON SUSAN
MOORE MARGARET
TAYLOR DOROTHY
Please choose the customer you want to see rentals for enter to go to the next page or to go to the previous page:
ANDERSON LISA
THOMAS NANCY
JACKSON KAREN
WHITE BETTY
HARRIS HELEN
MARTIN SANDRA
THOMPSON DONNA
GARCIA CAROL
MARTINEZ RUTH
ROBINSON SHARON
Please choose the customer you want to see rentals for enter to go to the next page:
SMITH MARY
JOHNSON PATRICIA
WILLIAMS LINDA
JONES BARBARA
BROWN ELIZABETH
DAVIS JENNIFER
MILLER MARIA
WILSON SUSAN
MOORE MARGARET
TAYLOR DOROTHY
Customer Information
Name: ELIZABETH BROWN
Address: Idfu Parkway
Nantou, Nantou
Phone Number:
Email: ELIZABETH.BROWN@sakilacustomer.org
Last Update: ::
Please choose an option enter to quit:
View the rentals for a customer
View Customer Information
Enter Choice: Heres is the main: "int main
int choice;
sqlitemydb;
int rc;
Need to add code to open the database.
cout "Welcome to Sakila" endl;
choice mainMenu;
while true
switch choice
case : viewRentalmydb; break;
case : viewCustomermydb; break;
case : return ;
default: cout "That is not a valid choice." endl;
cout
;
choice mainMenu;
Here is the viewCustomer: "void viewCustomersqlitedb
this is where your code goes.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started