Leute ich bin zu dumm hierfür... wie kann ich Unterprogramme in dieses Menü einfügen?
import java.util.Scanner;
public class Vorlage_Menue{
static void up1 (){
System.out.println("Das ist UP 1");
}
static void up2 (){
System.out.println("Das ist UP 2");
}
public static void main(String[] args){
Scanner sc= new Scanner(System.in);
int auswahl;
boolean exit = false;
while (exit == false) {
System.out.println("\nMein Menue");
System.out.println("1: Unterprogramm 1 ausführen");
System.out.println("2: Unterprogramm 2 ausführen");
System.out.println("9: Programm beenden");
System.out.print("Ihre Wahl: ");
auswahl = sc.nextInt();
switch (auswahl) {
case 1:
up1();
break;
case 2:
up2();
break;
case 9:
System.out.println("Ende");
exit = true;
break;
default:
System.out.println("Ungueltige Eingabe");
}
}
System.out.println("Bye Bye");
}
}
Würde mich über Antworten freuen
import java.util.Scanner;
public class Vorlage_Menue{
static void up1 (){
System.out.println("Das ist UP 1");
}
static void up2 (){
System.out.println("Das ist UP 2");
}
public static void main(String[] args){
Scanner sc= new Scanner(System.in);
int auswahl;
boolean exit = false;
while (exit == false) {
System.out.println("\nMein Menue");
System.out.println("1: Unterprogramm 1 ausführen");
System.out.println("2: Unterprogramm 2 ausführen");
System.out.println("9: Programm beenden");
System.out.print("Ihre Wahl: ");
auswahl = sc.nextInt();
switch (auswahl) {
case 1:
up1();
break;
case 2:
up2();
break;
case 9:
System.out.println("Ende");
exit = true;
break;
default:
System.out.println("Ungueltige Eingabe");
}
}
System.out.println("Bye Bye");
}
}
Würde mich über Antworten freuen