Question: This problem uses modular design in python programming, using pycharm. This program has three tasks at the top level: input prices of items, input coupons
This problem uses modular design in python programming, using pycharm.
This program has three tasks at the top level: input prices of items, input coupons 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.
| Function | Specification |
| scanPrices() | This function gets the price of each item purchased. The customer enters the prices one by one with a loop. When there is no more prices to enter, -1 is entered to exit the loop. The function calculates and returns the total price of all items. |
| scanCoupons() | This function gets the value of each coupon entered by the customer. The customer enters the coupon values one by one with a loop. When there is no more coupons to enter, -1 is entered to exit the loop. The function calculates and returns the total value of all coupons. |
| makePayment(balance) | This function allows the user to choose payment type [1 for cash, 2 for debit]. It receives balance as argument, and pass it to pay_cash and pay_debit. |
| payCash(balance) | This function receives cash payment. The self-checkout machine only accepts $10, $5 and $1 bills. Ask the user how many $10, $5 and $1 bills he is going to use. Calculate and display total payment. If customer has paid more than the balance, calculate and display change. |
| payDebit(balance) | This function receives debit payment. It asks customer to enter a 16-digit card number and a 4-digit PIN. It also asks customer to enter payment amount. Use a validation loop to ensure that payment is not lower than balance. If payment is higher than balance, calculate and display cash back amount. |
| main() | This function calls the scanPrices function to input item prices, calls the scanCoupons function to input coupon values. Calculates customers balance and pass it to the makePayment function. |
sample output paying with cash:
Welcome to the self-checkout system of Wake-mart
Enter price of first item [or -1 to stop]: 15
Enter price of next item [or -1 to stop]: 7
Enter price of next item [or -1 to stop]: 9
Enter price of next item [or -1 to stop]: 4
Enter price of next item [or -1 to stop]: -1
Balance: 35.0
Enter value of first coupon [or -1 to stop]: 2
Enter value of next coupon [or -1 to stop]: 1.5
Enter value of next coupon [or -1 to stop]: -1
New balance: 31.5
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? 3
How many $5 bills are you going to pay? 1
How many $1 bills are you going to pay? 0
Total cash paid: 35
Change: 3.5
sample out put with card:
Welcome to the self-checkout system of Wake-mart
Enter price of first item [or -1 to stop]: 15
Enter price of next item [or -1 to stop]: 7
Enter price of next item [or -1 to stop]: 9
Enter price of next item [or -1 to stop]: 4
Enter price of next item [or -1 to stop]: -1
Balance: 35.0
Enter value of first coupon [or -1 to stop]: 2
Enter value of next coupon [or -1 to stop]: 1.5
Enter value of next coupon [or -1 to stop]: -1
New balance: 31.5
Payment options:
Enter 1 for cash, 2 for debit: 2
Please enter a 16-digit card number: 1234567887654321
Please enter 4-digit pin: 9876
Please enter payment amount: 31
ERROR: Payment amount cannot be smaller than balance
Please enter payment amount: 40
Cash back: 8.5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
