Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CODING IN PYTHON: Assume a customer is at a store purchasing exactly 4 items. Th

ID: 3855077 • Letter: C

Question

CODING IN PYTHON:

Assume a customer is at a store purchasing exactly 4 items. The cashier inputs the items and their prices into the computer. Someone has provided the cashier a Python program that does the following:

1. Asks cashier for name of each item (use short names like nails, paint, etc.)

2. Asks cashier for price of each item

A) Assume items are between $5 & $20. Have 1 item that is less than $10

3. Prints receipt header (see below for a sample receipt)

4. Prints item name and price as they are entered (Do this step four times, once for each product)

A) Input item name, item price, then print them

B) Keeps a running total

C) Keeps a running count of number of items purchased

5. Calculates and prints tax amount based on a certain tax rate

A) Use a CONSTANT to store tax rate

6. Prints a total that includes tax amount

7. Prints how much cash a person pays

A) Assume customer pays the exact or higher amount

8. Prints the amount of change (if any) to be returned to customer

Please note the following:

- Right-justify amounts

- Show $ signs

- Right justify items shown

- Leave plenty of blank lines in program for readability

- Have at least 4 - 5 comments

- Include pseudocode, englishcode, or flowchart (don’t need all, just one of the three)

SAMPLE RECEIPT

__ ITEMS PURCHASED

______________________________________

Item 1

$__.__

Item 2

$_.__

Item 3

$__.__

Item 4

$_.__

Total (for 4 items)

$__.__

Tax - _%

$_.__

Total (incl. tax)

$__.__

Customer Paid

$__.__

Change to customer, if any

$__.__

Item 1

$__.__

Item 2

$_.__

Item 3

$__.__

Item 4

$_.__

Total (for 4 items)

$__.__

Tax - _%

$_.__

Total (incl. tax)

$__.__

Customer Paid

$__.__

Change to customer, if any

$__.__

Explanation / Answer

Code:

prices = []

for i in range(4):
print("Enter the price of Item %d:"%(i+1))
price = int(raw_input(""))
while(price <= 5 or price >= 25):
print("Enter the price of Item %d:"%(i+1))
price = int(raw_input(""))
  
prices.append(price)

tax = 15
total = sum(prices)
taxAmount = total*(tax/100.0)
totalWithTax = total + taxAmount

customerPaid = int(raw_input("Customer paid is: "))
changeToCustomer = 0
if (customerPaid > totalWithTax):
changeToCustomer = customerPaid - totalWithTax
print(" SAMPLE RECEIPT OF ITEMS PURCHASED Item 1: $.%.2f Item 2: $.%.2f Item 3: $.%.2f Item 4: $.%.2f Total(for 4 items) $.%.2f Tax-%d %% $.%.2f Total(icl tax) $.%.2f Customer Paid $.%.2f Change to Customer $.%.2f "%(prices[0],prices[1],prices[2],prices[3],total,tax,taxAmount,totalWithTax,customerPaid,changeToCustomer))

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote