import java.util.Scanner;


public class MyBank {

    private double money = 0;
    
    
    
    public boolean Savemoney(double savemoney){//存款
        if(savemoney>=0){
            this.money+=savemoney;
        }
        return false;
    }
    
    public boolean Takemoney(double takemoney){//取款
        if(this.money>=takemoney){
            this.money -= takemoney;
            return true;
        }
        return false;
    }
    
    public double GetBalance(){//查看余额
        return this.money;
    }
    public static void main(String[] args){
        int num = 0;
        double money ;
        Bank moneyAccount = new Bank();
        Scanner input = new Scanner(System.in);
        do{
            System.out.println("***当前余额为:"+moneyAccount.getBalance()+"元***");
            System.out.println("1:存款\t2.取款\t0.退出");
             System.out.println("请选择你需要办理的业务:");
             try{
                 num = input.nextInt();//录入菜单数字
             }
             catch (Exception e){
                 num = 0;
             }
             if( num == 1 ){
                 System.out.println("请输入存款金额:");
                 try{
                     money = input.nextDouble();//录入存款    
                     if(moneyAccount.SaveMoney(money)){
                         System.out.println("存款成功");
                     }
                     else{
                         System.out.println("存款失败,存款金额必须大于0");
                     }
                 }
                 catch (Exception e){
                     System.out.println("存款失败,请确定输入正确!");
                 }
             }
             else if(num ==2 ){
                 System.out.println("请输入取款金额:");
                 try{
                     money = input.nextDouble();//录入存款
                     if(moneyAccount.GetMoney(money)){
                         System.out.println("取款成功");
                     }
                     else{
                         System.out.println("取款失败,余额不足");
                     }
                 }
                 catch (Exception e){
                     System.out.println("取款失败,请确定输入正确!");    
                 }
             }
             
        }
        
        while (num != 0);
        
    }
    
}