这是一个带有切换菜单的do..while循环..
我试图让用户能够返回
菜单System.out.println("Options: (C)reate, (R)ead, (W)rite, (L)ist, (S)ave or (E)xit. (*****)");
但经过多次试验和错误后,我仍然无法在选择C,R,W,L或S后返回主菜单。
以下是代码的简短摘要..
do {
System.out.println("Options: (C)reate, (R)ead, (W)rite, (L)ist, (S)ave or (E)xit.
(*****)");
Scanner switchC = new Scanner(System.in);
System.out.println("Please enter your choice: ");
choice = switchC.next().charAt(0);
switch (Character.toUpperCase(choice)) {
case 'C':
System.out.println("C");
break;
case 'R':
break;
case 'W':
break;
case 'L':
break;
case 'S':
break;
case 'E':
System.exit(1);
default:
System.out.println("Options: (C)reate, (R)ead, (W)rite, (L)ist, (S)ave or (E)xit. (*****)");
}
} while(choice!='E');
答案 0 :(得分:1)
试
do{
}
while(Character.toUpperCase(choice) !='E')