我希望程序在切换案例完成或结束后返回菜单,但我不知道该怎么做。这是我的代码。例如,当用户选择了他/她的选择并且他/她已经执行了它时,程序会自动关闭,但我不希望它继续直到用户希望退出程序。请帮助我不知道该怎么办
public class Jproj
{
public static void main(String[] args)
{
boolean back = false;
String teamone = null;
String teamtwo = null;
LinkedList x = new LinkedList();
String name;
int team;
char choice = 'w';
int num=0;
System.out.println("Menu");
System.out.println("a.) Add a member");
System.out.println("b.) Define the friends of each member");
System.out.println("c.) Create two teams");
System.out.println("d.) Save Data");
System.out.println("e.) Extract data from file");
Sysmte.out.println("f.) Exit");
Scanner ans = new Scanner(System.in);
System.out.print("Choice:");
choice = ans.next().charAt(0);
switch(choice)
{
case 'a':
Scanner a = new Scanner(System.in);
System.out.println("ADDING MEMBERS");
System.out.print("Name of the member:");
name = a.nextLine();
System.out.println(""+name);
x.insert(name);
x.displayone();
System.out.print("Successfull!");
break;
case 'b':
System.out.println("DEFINING FRIENDS OF MEMBERS");
break;
case 'c':
System.out.print("Creating TEAMS");
Scanner scanner = new Scanner(System.in);
if(teamone!=null&&teamtwo!=null)
{
System.out.print("Teams has already been created!\n do you want to replace team names?");
System.out.print("1-Yes\n2-No");
int sagot = scanner.nextInt();
if(sagot != 1)
{
return;
}
else
System.out.println("CREATING TEAMS");
Scanner c = new Scanner(System.in);
System.out.print("Enter new Name of Team 1:");
teamone = c.nextLine();
System.out.print("Enter new Name of Team 2:");
teamtwo = c.nextLine();
x.teamname(teamone,teamtwo);
}
else
System.out.println("CREATING TEAMS");
Scanner c = new Scanner(System.in);
System.out.print("Name of Team 1:");
teamone = c.nextLine();
System.out.print("Name of Team 2:");
teamtwo = c.nextLine();
x.teamname(teamone,teamtwo);
System.out.print("Teams has been successfully created!");
System.out.print("Current members:");
x.displaytwo();
break;
case 'd':
System.out.println("SAVING DATA");
break;
case 'e':
break;
case 'f':
return;
enter code herebreak;
}
}
}