Anzahleingabe optimiert

This commit is contained in:
Joel Baldauf
2020-12-15 13:32:59 +01:00
parent 5cad96d6d5
commit 1131f0ab5a
+5 -3
View File
@@ -11,14 +11,16 @@ class Fahrkartenautomat
System.out.print("Ticketpreis (EURO): ");
zuZahlenderBetrag = tastatur.nextDouble();
while (true) {
System.out.print("Anzahl der Tickets: ");
anzahlTickets = tastatur.nextByte();
while (!(anzahlTickets > 0 && anzahlTickets <= 10)) {
if (!(anzahlTickets > 0 && anzahlTickets <= 10)) {
System.out.print("Es wurde ein ungültiger Wert für die Ticketanzahl eingegeben. \n"
+ "Bitte erneut versuchen.\n"
+ "Anzahl der Tickets: ");
anzahlTickets = tastatur.nextByte();
continue;
}
break;
}
zuZahlenderBetrag = anzahlTickets * zuZahlenderBetrag;