There is a major snow storm coming and your store is selling those essential items needed by everyone. Users will have the option to buy Milk, Bread, Eggs and Toilet Paper from your store. You need to create a program to allow the users to buy each of these items and then display the total due at the end.

Follow the sample output below and place your name as the owner of the store (Snow 'R' Us).

Using a menu, your program should ask the user what item he/she wants to purchase. If the user indicates an item that your store does not sell, an error message should display telling the user that you do not sell that item.

If the user indicates a valid item, asl the user how many of the item he/she wants to buy. Make sure that the input is a positive number greater than zero before proceeding. If the value is not positive, make sure the user has the ability to reenter the value until they enter in a valid value.

Calculate and display the subtotal to the user. The prices are as follows:

Milk is $6.25 per gallon. You can only buy whole number gallons.

Bread is $2.25 per loaf, unless the user enters the coupon code "bread1". If the user enters the correct code, bread is $1.50 per loaf. The only valid entries for the coupon code is "bread1" or "NONE". Any other entry should be flagged as invalid and the user should be allowed to reenter the coupon code.

Eggs are $2.00 for each half dozen or $3.50 for each full dozen. If the user buys at least two gallons of milk, they get eggs for half price. This discount is only applied at the very end when calculating the final total. The program should indicate the amount of the discount.

Toilet Paper: 1-5 rolls: $1.99 each
6-10 rolls: $1.49 each
11 or more: $0.99 each

This process of allowing the user to select an item and your program displaying the subtotal should continue until the user selects to exit when prompted for the item he/she wants to purchase. Your program should then display the total amount due and the total amount of the discount (if there is any).

EXTRA CREDIT:

Keep track of the number of rolls of toilet paper. Calculate the total cost of the toilet paper based on the total number of rolls purchased accumulated over time. For Example:

If the user buys 5 rolls of toilet paper, the cost is (5 * $1.99) = $9.95

The user then goes in and buys another 5 rolls. In the base program, the subtotal cost of the toilet paper would be (5 * $1.99) + (5 * $1.99) = $19.90. In the extra credit version of the program, the subtotal cost of the toilet paper should now be (10 * $1.49) = $14.90.

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.