Question: Write a program that enables DBVac employees to look up a customer by name, then output the data regarding the matching customer(s) and their orders.
Write a program that enables DBVac employees to look up a customer by name, then output the data regarding the matching customer(s) and their orders. Your program should:
- Include comments describing each major section of code.
- Connect to the included SQLite version of the DBVac database (dbvac_sqlite.db).
- Ask the user to input a first name.
- Validate that the user has entered an actual (non-blank) value. If they leave this blank, keep asking the user for a name until they enter something valid.
- Ask the user to input a last name.
- Validate that they have entered an actual (non-blank) value . If they leave this blank, keep asking the user for a last name until they enter something valid.
- Run a SQL query to get the information about the customer(s) whose names match the user's input.
- If there is no matching customer in the database, report this to the user and skip to step 6 below.
- If there is a matching customer, output the customers ID, first name, last name, the NAME of the state that the customer is from, the NAME of the region that the customer is from, the customers household income, marital status, number of children, and whether or not they have pets.
- Note that its possible that there is more than one customer with the same first and last name. If this is the case, output this information for each of them (unless pursuing the extra credit below).
- Print each of these on a separate line and provide labels for each (e.g., CustID: 1 Last Name: Belle First Name: Richard ...).
- In addition, query and then output information for each order placed by that customer. For each of the customers orders, include the SOID, order date, total spent (hint: use LineTotal), and the number of items, excluding warranties, sold as part of the order (make sure each unit is accounted for in the number of items on the order if they bought one unit of model A and two units of Model B, that is three total items).
- Print each of these on the same line and provide labels for each (e.g., SOID: 804, Date: 2023-04-17, ...).
- Note that if more than one customer has the same first and last name, you should output all the orders for all customers with that name (unless pursuing the extra credit below).
- Ask the user if they want to look up another customer and, if so, go through this same process again.
- Remember to validate that the user enters either a y or a n. Otherwise, keep asking until they enter something correct. (And remember to make the input case insensitive ;)
- Once the user is done entering records:
- Tell the user how many customers they looked up during the session.
- Say thank you and tell the user, forcefully, to have a nice day.
- Two Extra Credit Points: Check to see if there are multiple customers with the same first and last name.
- If so, output to the user the Customer ID, first name, last name, and state name for each of the customers.
- Then, ask the user to provide the Customer ID for the specific customer they want to look up.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
