Answered step by step
Verified Expert Solution
Link Copied!

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 menu-based 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 2. 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 -1 to quit):
1. View the rentals for a customer
2. View Customer Information
Enter Choice: 1
There are 599 rows in the result. How many do you want to see per page?
10
Please choose the customer you want to see rentals for (enter 0 to go to the next page):
1.1- MARY SMITH
2.2- PATRICIA JOHNSON
3.3- LINDA WILLIAMS
4.4- BARBARA JONES
5.5- ELIZABETH BROWN
6.6- JENNIFER DAVIS
7.7- MARIA MILLER
8.8- SUSAN WILSON
9.9- MARGARET MOORE
10.10- DOROTHY TAYLOR
0
Please choose the customer you want to see rentals for (enter 0 to go to the next page or -1 to go to the previous page):
11.11- LISA ANDERSON
12.12- NANCY THOMAS
13.13- KAREN JACKSON
14.14- BETTY WHITE
15.15- HELEN HARRIS
16.16- SANDRA MARTIN
17.17- DONNA THOMPSON
18.18- CAROL GARCIA
19.19- RUTH MARTINEZ
20.20- SHARON ROBINSON
15
There are 33 rows in the result. How many do you want to see per page?
10
Please choose the rental you want to see (enter 0 to go to the next page):
1.2486-2005-06-1821:26:56
2.2937-2005-06-2005:15:37
3.3182-2005-06-2022:52:18
4.3550-2005-07-0602:29:21
5.4127-2005-07-0707:26:19
6.5717-2005-07-1011:02:03
7.5975-2005-07-1100:14:19
8.7105-2005-07-2705:15:37
9.8193-2005-07-2822:50:50
10.8615-2005-07-2913:36:01
5
Rental Date: 2005-07-0707:26:19
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 $4.99
Return Date: 2005-07-1407:50:19
Please choose an option (enter -1 to quit):
1. View the rentals for a customer
2. View Customer Information
Enter Choice: 2
Please choose the customer you want to see:
There are 599 rows in the result. How many do you want to see per page?
10
Please choose the customer you want to see rentals for (enter 0 to go to the next page):
1.1- SMITH MARY
2.2- JOHNSON PATRICIA
3.3- WILLIAMS LINDA
4.4- JONES BARBARA
5.5- BROWN ELIZABETH
6.6- DAVIS JENNIFER
7.7- MILLER MARIA
8.8- WILSON SUSAN
9.9- MOORE MARGARET
10.10- TAYLOR DOROTHY
0
Please choose the customer you want to see rentals for (enter 0 to go to the next page or -1 to go to the previous page):
11.11- ANDERSON LISA
12.12- THOMAS NANCY
13.13- JACKSON KAREN
14.14- WHITE BETTY
15.15- HARRIS HELEN
16.16- MARTIN SANDRA
17.17- THOMPSON DONNA
18.18- GARCIA CAROL
19.19- MARTINEZ RUTH
20.20- ROBINSON SHARON
-1
Please choose the customer you want to see rentals for (enter 0 to go to the next page):
1.1- SMITH MARY
2.2- JOHNSON PATRICIA
3.3- WILLIAMS LINDA
4.4- JONES BARBARA
5.5- BROWN ELIZABETH
6.6- DAVIS JENNIFER
7.7- MILLER MARIA
8.8- WILSON SUSAN
9.9- MOORE MARGARET
10.10- TAYLOR DOROTHY
5
----Customer Information----
Name: ELIZABETH BROWN
Address: 53 Idfu Parkway
Nantou, Nantou 42399
Phone Number: 10655648674
Email: ELIZABETH.BROWN@sakilacustomer.org
Last Update: 2006-02-1504:57:20
Please choose an option (enter -1 to quit):
1. View the rentals for a customer
2. View Customer Information
Enter Choice: -1 Heres is the main: "int main()
{
int choice;
sqlite3*mydb;
int rc;
Need to add code to open the database.
cout << "Welcome to Sakila" << endl;
choice = mainMenu();
while (true)
{
switch (choice)
{
case 1: viewRental(mydb); break;
case 2: viewCustomer(mydb); break;
case -1: return 0;
default: cout << "That is not a valid choice." << endl;
}
cout <<"
";
choice = mainMenu();
}
}" Here is the viewCustomer: "void viewCustomer(sqlite3*db)
{ this is where your code goes.
}"

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions

Question

What is the preferred personality?

Answered: 1 week ago

Question

4. Show the trainees how to do it again.

Answered: 1 week ago

Question

8. Praise the trainees for their success in learning the task.

Answered: 1 week ago