import java.util.Scanner;
public class ATM{
public static void main(String... args){
Scanner sc=new Scanner(System.in);
double money=0;
do{
System.out.println("请选择业务:1)查询余额 2)取款 3)存款 4)退出");
int c=sc.nextInt();
if(c==1){
System.out.println("用户余额为:"+money+"元");
}else if(c==2){
while(true){
System.out.println("请输入取款金额:");
double load=sc.nextDouble();
if(load>=money){
System.out.println("账户余额不足,请重新输入取款金额");
continue;
}else{
money-=load;
System.out.println("取款成功");
break;
}
}
}else if(c==3){
System.out.println("请输入存款金额:");
money+=sc.nextDouble();
System.out.println("存款成功");
}else if(c==4){
System.exit(0);
}else{
System.out.println("输入错误,请重新选择业务");
}
}while(true);
}
}