Question: Create a Python project for each of the problems in this lab. Problem 1 This problem is about modular design. We are writing a program

Create a Python project for each of the problems in this lab.

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.

Create a Python project for each of the problems in this lab.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.

The following is an example. This customer chooses to pay 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

The following is another example. This customer chooses to pay by debit.

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

File Paste Teh Copy B I U at Painter A Sehar Abbas CSC 121 Lab 12020 lCompatibility Model Word Review view 9 Tel me what you want to do AaBbce AAt AABBC Aabb cel AABB AABBC AABBCC INommal Style CIS No spacing Heading 1 Heading 2 Heading 3 Heading 4 Tit Subtitle Subtle Em.. INSTRUCTION AND PROBLEMS Create a Python project for each of the problems in this lab. 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. Main Input prices Process payment input coupons Cash Debit English NT ou P x Share p Find Replace select rting 220 AM NG 4/12/2017

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!