There is a major snowstorm coming and your store is selling those essential items needed by everyone. Customers will have the option to buy Milk, Bread, Eggs and Toilet Paper from your store. You need to create an algorithm (using Pseudo code) to allow the customers to buy each of these items and then display the total due at the end.

Your algo should display the owner of the store. Place your name as the owner of the store.

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

If the customer indicates a valid item, ask the customer 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 customer has the ability to reenter the value until they enter in a valid value.

Calculate and display the subtotal to the customer. 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 customer enters the coupon code ‘R’. If the customer enters the correct code, bread is $1.50 per loaf. The only valid entries for the coupon code are ‘R’ or ‘N’. Any other entry should be flagged as invalid and the customer 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 customer buys at least two gallons of milk, they get eggs for half price. This egg discount is only applied at the very end when calculating the final total. The algo should indicate the amount of the egg discount only if there is a 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 customer to select an item and your algo displaying the subtotal should continue until the customer 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 customer buys 5 rolls of toilet paper, the cost is (5 * $1.99) = $9.95

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


Sagot :