怎么返回上一层?
import java.util.*;public class test{
public static void main(String[] args){
System.out.println("请按提示输入!");
System.out.println("1、查询余额2、取款3、转账、4、退出取卡");
Scanner input=new Scanner(System.in);
int money=input.nextInt();
//想在这里加个循环,让它第四次的时候重新输入,并且输入次数有限为三!怎么做?
switch(money){
case 1:
System.out.println("这是500元,请收好!");
break;
case 2:
System.out.println("请输入要转账的金额:");
System.out.println("请输入要转账的账号:");
break;
case 3:
System.out.println("请将卡收好!");
break;
case 4:
System.out.println("输入有误!请重新输入!");
}
}
}
}
----------------解决方案--------------------------------------------------------
public static void main(String[] args)
{
// TODO Auto-generated method stub
boolean isContinue = true;
int count = 0;
while(isContinue && count < 3)
{
System.out.println("make your choice");
int choice;
read in choice here
switch(choice)
{
case 1: ****;
break;
case 2: ****;
break;
case 3: ****;
break;
case 4: ****;
break;
default : should never reach here;
break;
}
String wantContinue;
println("continue ? yes or No")
read in wantContinu;
if("yes".equals(wantContinue.toLowerCase()))
{
isContinue = true;
count++;
}
else if("no".equals(wantContinue.toLowerCase()))
{
isContinue = false;
}
else
{
println(wrong answer);
exit(1);
}
}
}
----------------解决方案--------------------------------------------------------
"让它第四次的时候重新输入,并且输入次数有限为三!"
看不懂...
有限为三,怎么还有第四次重新输入?
----------------解决方案--------------------------------------------------------