Question: Problem 1 This problem is about modular design. We are writing a program to simulate a self-checkout system of a store named Wake-Mart. This program
Problem 1
This problem is about modular design. We are writing a program to simulate a self-checkout system of a store named Wake-Mart.
This program has four tasks at the top level: input prices of items, process discount, process promotion, and process payment. Processing of payment is further divided into two subtasks. The customer can choose either to pay by cash or by debit card.
You must write the following functions to implement the design above.
The following is an example. This customer chooses to pay cash.
Welcome to the self-checkout system of Wake-mart
Enter the price of first item [or 0 to stop]: 7
Number of items: 1 Total: 7.0
Enter price of next item [or 0 to stop]: -2
Price cannot be negative
Enter price of next item [or 0 to stop]: -5
Price cannot be negative
Enter the price of next item [or 0 to stop]: 8
Number of items: 2 Total: 15.0
Enter the price of next item [or 0 to stop]: 2.5
Number of items: 3 Total: 17.5
Enter the price of next item [or 0 to stop]: 8
Number of items: 4 Total: 25.5
Enter the price of next item [or 0 to stop]: 7
Number of items: 5 Total: 32.5
Enter the price of next item [or 0 to stop]: 5
Number of items: 6 Total: 37.5
Enter the price of next item [or 0 to stop]: 4.25
Number of items: 7 Total: 41.75
Enter the price of next item [or 0 to stop]: 8
Number of items: 8 Total: 49.75
Enter the price of next item [or 0 to stop]: 8.25
Number of items: 9 Total: 58.0
Enter the price of next item [or 0 to stop]: 2
Number of items: 10 Total: 60.0
Enter the price of next item [or 0 to stop]: 4
Number of items: 11 Total: 64.0
Enter the price of next item [or 0 to stop]: 6
Number of items: 12 Total: 70.0
Enter the price of next item [or 0 to stop]: 0
you've got 10% discount for buying 10 items or more.
Number of items: 12 Total: 63.0
Do you want to buy a $50 gift card for $40? [y/n] y
Thank you for buying a gift card.
Number of items: 13 Total: 103.0
Payment options:
Enter 1 for cash, 2 for debit: 1
This machine only accepts $10, $5 and $1 bills.
How many $10 bills are you going to pay? 9
How many $5 bills are you going to pay? 1
How many $1 bills are you going to pay? 1
Error: Total cash payment less than balance. Please re-enter.
How many $10 bills are you going to pay? 9
How many $5 bills are you going to pay? 3
How many $1 bills are you going to pay? 0
Total cash paid: 105
Thank you for your payment.
Change: 2.0
The following is another example. This customer chooses to pay by debt.
Welcome to the self-checkout system of Wake-mart
Enter the price of first item [or 0 to stop]: 7
Number of items: 1 Total: 7.0
Enter price of next item [or 0 to stop]: -2
Price cannot be negative
Enter price of next item [or 0 to stop]: -4
Price cannot be negative
Enter the price of next item [or 0 to stop]: 5
Number of items: 2 Total: 12.0
Enter the price of next item [or 0 to stop]: 6
Number of items: 3 Total: 18.0
Enter the price of next item [or 0 to stop]: 8
Number of items: 4 Total: 26.0
Enter the price of next item [or 0 to stop]: 1
Number of items: 5 Total: 27.0
Enter the price of next item [or 0 to stop]: 5
Number of items: 6 Total: 32.0
Enter the price of next item [or 0 to stop]: 6
Number of items: 7 Total: 38.0
Enter the price of next item [or 0 to stop]: 8
Number of items: 8 Total: 46.0
Enter the price of next item [or 0 to stop]: 9
Number of items: 9 Total: 55.0
Enter the price of next item [or 0 to stop]: 5
Number of items: 10 Total: 60.0
Enter the price of next item [or 0 to stop]: 0
you've got 10% discount for buying 10 items or more.
Number of items: 10 Total: 54.0
Do you want to buy a $50 gift card for $40? [y/n] n
Payment options:
Enter 1 for cash, 2 for debit: 2
Please enter a 16-digit card number: 1234567812345678
Please enter 4-digit pin: 9988
Please enter payment amount: 45
ERROR: Payment amount cannot be smaller than balance
Please enter payment amount: 54
Thank you for your payment.
Save your Python program in a file named Lab12P1.py. Submit the file for the credit.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
