Part 1

At this part, you program can perform simple interactions with user.

1. Display a message asking the user to enter the name of the customer.

. Display a message asking the user to enter the name of a product.

3. Display a message asking the user to enter the quantity of the product ordered by the customer that was entered earlier. Assume the quantity is always an integer e.g. 4, 8, 22

4. Calculate the total price for the customer including the discount (see No. 7 below).

5. You program should have a list to store customer names, and a list to store product names. Every product has a price in dollar e.g. $58.85, $0.50, $3990. You can assume product names and customer names are all unique.

6. In you program, write a short explanation on how products and their price are stored.

7. Your program will go through the customer list and the product list. For an existing customer, 10% discount will apply. No discount for new customers. Your program is now able to calculate the total price. Assume the search is case-sensitive e.g. John != john != johN.

8. The total price will be displayed as a formatted message to the user, e.g.

< customer name> purchased < quantity> x < product name>
Unit price: < product price>
Total price: < total price>

Part 2

At this part, you program can be operated using a menu to do the following:

1. Display an error message if the product name entered by the user does not exist in the list. If that occurs, the user will be given another chance, until an existing product is entered.

2. Display a message asking the user to enter a list of products. If there is already a product list, it will be replaced by the new list. You can assume the product names are always unique. Every product name is a single word with no space but only alphanumeric characters.

3. Allow user to enter the prices as well. The newly entered prices will replace existing prices. The prices may be entered as a list. You can assume the order is the same as the order of products. For example if "1 2 3.5" is the price list for products A B C D E, A, B, C are then set prices as $1, $2 and $3.5 respectively.

4. A product may have no price. Products D and E in the above example have no price.

5. When a new customer made an order, this customer will be added to the customer list so the 10% discount will apply for all further purchases from this customer. You can assume duplicate names never happen.

6. Display all the existing customers on screen.

7. Display all the products in the list on screen, with their prices. Products with no price will also be displayed.

8. When a task is accomplished, the menu will appear again for the next task. The program always exits gracefully from the menu, e.g. there is an exit option on the menu.

Part 3

At this part, you program is equipped with some advanced features. Note some features may be challenging.

1. All negative prices are treated as no price or price unknown. A product with no price cannot be sold. An error message will show if the user attempts to order such products.

2. A new customer cannot order a free product, e.g. its price is zero.

3. Through the menu, user can invoke a function named as "replenish", which sets the stock of all products to a number entered by the user. For example, if the user entered 50, then every product will have 50 in stock.

4. If a product does not have enough stock, the order will not proceed.

5. The menu now has an option to reveal the most valuable customer. That is based on the total order value. Note, one customer may have multiple orders.

6. Display the order information as a table to show who ordered what. For example

P1 P2 P3 P4
Linda 2 0 15 0
Jack 0 5 0 0
Zoran 10 0 0 11

Note: you can assume the product and the price lists will not change during these Part 3 operations, although updating products and prices is a routine operation in reality.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.