subject

Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file Prompt the user to enter the Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save the item name, quantity, item price, and extended price to a file When you create the file, prompt the user for the name they want to give the file Separate the items saved with commas Each entry should be on a separate line in the text file Ask the user if they have more items to enter Once the user has finished entering items Close the file with the items entered Display the sales total If the sales total is more than $100 Calculate and display a 10% discount Calculate and display the sales tax using 8% as the sales tax rate The sales tax should be calculated on the sales total after the discount Display the total for the sales receipt, I thought this would work (see below) but I keep getting errors:sales_total=0 Item_name=input("Enter the item name: ") Item_quantity=int(input("Enter the item quantity: ")) Item_price=int(input("Enter the item price $: ")) Extender_price=Item_price*Item_quan tity sales_total=sales_total+Extender_pr ice print("\nItem name:{}".format(Item_name)) print("Item quantity:{}".format(Item_quantity)) print("Item price:${}".format(Item_price)) print("Extended price:${}".format(Extender_price)) filename=input("Enter the filename:") f=open(filename+".txt","a+") #writing the values to file f. write((Item_name)+","+str(Item_quan tity)+","+str(Item_price)+","+str(E xtender_price)+"\n") while(True): option=input("Do you want to enter more items(Yes/No)?") if option. lower()=="yes": Item_name=input("Enter the item name: ") Item_quantity=int(input("Enter the item quantity: ")) Item_price=int(input("Enter the item price: ")) Extender_price=Item_price*Item_quan tity sales_total=sales_total+Extender_pr ice print("\nItem name:{}".format(Item_name)) print("Item quantity:{}".format(Item_quantity)) print("Item price:${}".format(Item_price)) print("Extended price:${}".format(Extender_price)) f. write((Item_name)+","+str(Item_quan tity)+","+str(Item_price)+","+str(E xtender_price)+"\n")#writing them to the file f. close() #closing the file else: break sales_tax=8 if sales_total>100: discount_value=sales_total*(10/100) sales_total=sales_total-discount_va lue tax=sales_total*(sales_tax/100) total=sales_total-tax print("Discount:\t-",discount_value ) print("Sales tax:\t+",tax) print("After sales tax applied:",total) else: sales_total=sales_total-discount_va lue tax=sales_total*(sales_tax/100) total=sales_total-tax print("Discount:\t-",discount_value ) print("Sales tax:\t+",tax) print("After sales tax applied:",total)

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 18:00, markleal9484
What ordering of tcp flags makes up the three-way handshake?
Answers: 2
image
Computers and Technology, 21.06.2019 23:00, pinkyglitter2696
Give an example of a case where a two-way handshake to establish a connection could leave one side of the connection live while the other side does not believe there is a connection.
Answers: 1
image
Computers and Technology, 22.06.2019 09:40, cutybrain6054
Sarah is having a hard time finding a template for her advertising business that she may be able to use at a later date and also make it available to her colleagues
Answers: 1
image
Computers and Technology, 22.06.2019 19:10, hgdthbgjnb83661
What a backup plan that you have created in a event you encounter a situation
Answers: 2
You know the right answer?
Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves t...

Questions in other subjects:

Konu
Mathematics, 19.04.2021 17:20