Ich habe Problem mit einem do while-Schleife. Wenn ich das Programm ausführe, geht es zuerst durch das Menü, dann führe den Code aus, aber dann beendet es das Programm.Do While-Schleife mein Programm endet
public class Draft {
static Scanner input = new Scanner(System.in);
static Holding[]holding = new Holding[15];
static int hold = 0;
private static Scanner scanner;
public static void main(String[] args){
int options;
do{
scanner = new Scanner(System.in);
for(int i = 0; i <=50; i++){
System.out.print("=");
}
System.out.println();
System.out.println("Library Management System");
for(int i = 0; i <=50; i++){
System.out.print("=");
}
System.out.println();
System.out.println();
System.out.println("1. Add Holding");
System.out.println("2. Remove Holding");
System.out.println("3. Exit);
options = scanner.nextInt();
switch(options){
case 1:
addHolding();
break;
case 2:
removeHolding();
default:
System.out.println("Please");
}
}while(options == 3);
System.out.println("I'm out");
public void addHolding(){
int option = input.nextInt();
switch(option)
case 1:
addBook();
break;
case 2:
addVideo();
break;
default:
System.out.println("Please select the following option");
public static void addBook{
(execute code)
}
Nach dem Ausführen der AddBook-Methode beendet es das Programm. Meine Frage ist
Was muss ich beheben für meinen Code in das Menü zurück, anstatt zu beenden mein Programm
Dank
Vielen Dank für Ihre Hilfe: D – HelpwAssignments