Python Forum
Help!! Order form and receipt code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help!! Order form and receipt code
#1
Hi!
I am having such a hard time creating my code its for a donut shop order form you enter your name and once you select ur type, and quantity it prints out a recipt like the one below.. I have everything figured out EXCEPT, I cant figure out how to multiply the quantity by the price.. any assistance would be so greatly appreciated, im new to this and struggling so hard. Ive also attached what i have so far for my code that is working

Output:
Dave, here is your receipt: ------------------------------- 12 Chocolate-dipped Maple Puffs ------------------------------- Total cost: $42.00. Thank you, have a nice day!
print("Welcome, to Dino's International Doughnut Shoppe!")
name = input("Please enter your name to begin!:")

fileout= open("Dinos.txt", "w")
fileout.write(name + "\n") 
fileout.close()

print("Please select a doughnut from the following menu:")
print("1. Chocolate-dipped Maple Puff ($3.50 each)")
print("2. Strawberry Twizzler ($2.25 each)")
print("3. Vanilla Chai Strudel ($4.05 each)")
print("4. Honey-drizzled Lemon Dutchie ($1.99)")
x = int(input())
if x > 4:
    print("I'm sorry, that's not a valid selection. Please enter a selection from 1-4.")
    x= int(input())
    
if x == 1:
    print("How many Chocolate-dipped Maple Puffs would you like to purchase?")
    fileout= open("Dinos.txt","a")
    fileout.write("Chocolate- dipped Maple Puffs\n")
    fileout.write(str("3.50\n"))
    fileout.close()                         
if x == 2:
    print("How many Strawberry Twizzlers would you like to purchase?")
    fileout=open("Dinos.txt","a")
    fileout.write("Strawberry Twizzlers\n")
    fileout.write(str("2.25\n"))
    fileout.close()
if x == 3:
    print("How many Vanilla Chai Strudels would you like to purchase?")
    fileout=open("Dinos.txt","a")
    fileout.write("Vanilla Chai Strudels\n")
    fileout.write(str("4.05\n"))
    fileout.close()
if x == 4: 
    print("How many Honey-drizzled Lemon Dutchies would you like to purchase?")
    fileout=open("Dinos.txt","a")
    fileout.write("Honey-drizzled Lemon Dutchies\n")
    fileout.write(str("1.99\n"))
    fileout.close()

Qty=input()
fileout= open("Dinos.txt","a")
fileout.write(Qty + "\n")
fileout.close ()


filein= open("Dinos.txt","r")
for i in range(0-4):
    for line in "Dinos.txt":
        data = line.split("\n")
        name= data [0]
        itemCode= float(data[1])
        itemPrice = float(data[2])
        itemQty= float(data[3])
      

print(name + ", here is your recipt:")
print("-------------------------------")
itemCode= filein.readline().strip()
itemPrice=(filein.readline().strip())
itemQty= (filein.readline().strip())
print(Qty+ itemPrice)
print("-------------------------------")
print("Total cost: $")
print(itemQty*Qty )
print("Thank you, have a nice day")

filein.close()
Reply
#2
itemQty * itemPrice
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
@ichabod801
When I do that I receive,
TypeError: can't multiply sequence by non-int of type 'str'
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  In need help to put this code in order lekuru01 4 3,059 Apr-11-2019, 05:50 AM
Last Post: loomski
  Improve this code (Receipt alike) Leonzxd 10 7,723 Jun-26-2018, 03:33 PM
Last Post: Leonzxd
  Write a code to output in alphabetical order AbdelaliPython 1 4,556 Jan-19-2018, 09:03 PM
Last Post: j.crater
  Python Coding Homework Help "Grocery Store Receipt" cd3 3 12,570 Apr-12-2017, 02:10 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020