46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
# Programm, welches einen Getränkeatuomat simuliert
|
|
weiter_machen = True
|
|
gesamtpreis = 0
|
|
preis = 0
|
|
|
|
f1 = open("cola.txt")
|
|
f2 = open("wasser.txt")
|
|
f3 = open("saft.txt")
|
|
|
|
cola = float(f1.read())
|
|
wasser= float(f2.read())
|
|
saft= float(f3.read())
|
|
while (weiter_machen==True):
|
|
#Getränkeauswahl
|
|
print("Wählen Sie ein Getränk!")
|
|
print("1. Cola %s€"%(cola))
|
|
print("2. Wasser %s€"%(wasser))
|
|
print("3. Saft %s€"%(saft))
|
|
|
|
auswahl=int(input("Ihre Auswahl:")) # Nutzereingabe
|
|
if auswahl==1:
|
|
preis=cola
|
|
elif auswahl==2:
|
|
preis=wasser
|
|
elif auswahl==3:
|
|
preis=saft
|
|
else:
|
|
print("ERREUR, please nochmal from Vorne")
|
|
continue
|
|
# Anzahl der Getränke
|
|
anzahl=int(input("Wie viele Getränke wollen Sie? "))
|
|
preis=preis*anzahl
|
|
gesamtpreis=gesamtpreis+preis
|
|
print("Ihr Gesamtpreis beträgt %s€"%(gesamtpreis)) # Gesamtpreis ausgeben
|
|
|
|
# Weiteres Getränk?
|
|
weiter=input("Möchten Sie weitere Getränke bestellen? (j/n)")
|
|
if weiter=="j":
|
|
weiter_machen=True
|
|
continue
|
|
elif weiter=="n":
|
|
break
|
|
else:
|
|
print("ERREUR, please nochmal from Vorne")
|
|
continue
|