Anzahleingabe optimiert
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user