1
This commit is contained in:
14
3. Übungen/07.04.2022/Getränke_automat_1/Beipielautomat.md
Normal file
14
3. Übungen/07.04.2022/Getränke_automat_1/Beipielautomat.md
Normal file
@ -0,0 +1,14 @@
|
||||
# Getränkeautomat
|
||||
- Auswahl
|
||||
- Cola (1,50€)
|
||||
- Wasser (1,00€)
|
||||
- Saft (2,00€)
|
||||
|
||||
- Anzahl
|
||||
|
||||
- Weiteres Getränk?
|
||||
- Ja (von vorne)
|
||||
- Nein (Ausgabe Preis)
|
||||
|
||||
- Ausgabe Preis
|
||||
|
45
3. Übungen/07.04.2022/Getränke_automat_1/Beispielautomat.py
Normal file
45
3. Übungen/07.04.2022/Getränke_automat_1/Beispielautomat.py
Normal file
@ -0,0 +1,45 @@
|
||||
# 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
|
1
3. Übungen/07.04.2022/Getränke_automat_1/cola.txt
Normal file
1
3. Übungen/07.04.2022/Getränke_automat_1/cola.txt
Normal file
@ -0,0 +1 @@
|
||||
1.50
|
1
3. Übungen/07.04.2022/Getränke_automat_1/saft.txt
Normal file
1
3. Übungen/07.04.2022/Getränke_automat_1/saft.txt
Normal file
@ -0,0 +1 @@
|
||||
2.00
|
1
3. Übungen/07.04.2022/Getränke_automat_1/wasser.txt
Normal file
1
3. Übungen/07.04.2022/Getränke_automat_1/wasser.txt
Normal file
@ -0,0 +1 @@
|
||||
1.00
|
Reference in New Issue
Block a user