Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code needs to be written in python 3 You need to write the following functions to implement the design above. You must follow exactly

The code needs to be written in python 3

You need to write the following functions to implement the design above. You must follow exactly the specifications of this program. This includes following the exact naming convention for the functions, passing the functions parameters, and returning values from the functions, as stated. This also includes following the input and output as shown in the two examples below.

Function

Specification

scan_prices()

return

item_count,

total_price

This function gets the price of each item purchased. The customer enters the price of each item one by one within a while loop. When there are no more item prices to enter, 0 is entered to exit the loop. Whenever a negative price is entered, display Price cannot be negative and ask the user to enter next price. Every time a valid item price is entered, display the count of items entered so far and the total so far (exclude invalid entries). Return the item count and the total price of all items when the user has finished entering prices.

discount (count, total)

return

total

This function gives a 10% discount if 10 or more items are purchased. It receives the item count and the total price as arguments. It checks whether 10 or more items are purchased, and it reduces the total by 10% if the 10 or more items requirement is met. This function returns the total, whether it has been changed or not.

promotion (count, total)

return

count, total

This function allows the user to buy a gift card with a discount. It receives the item count and the total price as arguments. If the total is $50 or higher, the user can choose to buy one $50 gift card for the price of $40. Update the items count and total price if the user chooses to buy a gift card. This function returns items count and total price, whether they have been changed or not.

make_payment (amtDue)

This function allows the user to choose the payment type [1 for cash, 2 for debit]. It receives the amount due as an argument, and calls pay_cash or pay_debit passing them the amount due.

pay_cash (amtDue)

This function processes a cash payment. It receives the amount due as an argument. The bills accepted are $10, $5 and $1. Ask the user how many $10, $5 and $1 bills she is going to use. Calculate and display the total payment. Use an input validation while loop to ensure that the payment is not lower than the amount due. If it is, ask the user to re-enter the amount of each $10, $5 and $1 bills used to pay the bill. If the customer has paid more than the amount due, calculate and display the change.

pay_debit (amtDue)

This function receives an amount due as its parameter. It asks the customer to enter a 16-digit card number and a 4-digit PIN. It also asks the customer to enter the payment amount. Use an input validation while loop to ensure that payment is not lower than the amount due. If it is, ask the user to re-enter payment amount. If the payment is higher than the amount due, calculate and display the cash back amount.

main()

This function calls the scan_prices function to input grocery item prices, calls the discount function to process the discount, calls the promotion function to process the gift card promotion, and calls the make_payment function to process the payment.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions