java银行存款取款

package April;

import java.util.Scanner; public class B5 {

double account = 0;

public double getAccount(){ return account; }

public void deposit(double number){ account = account + number; System.out.println(\存款成功!\); System.out.println(\当前余额为:\+getAccount()+\元***\); }

public void take(double number){ if(getAccount() > number){ account = account - number; System.out.println(\取款成功\); System.out.println(\当前余额为:\+getAccount()+\元***\); } else{

System.out.println(\余额不足,取款失败!\); } }

public static void main(String[] args){ int choice ; B5 ac = new B5(); double money = 0;

Scanner input = new Scanner(System.in); do{

System.out.println(\存款 2.取款 0.退出\); System.out.print(\请选择你需要办理的业务:\); choice = input.nextInt(); switch(choice){

case 0: choice =0; break; case 1:

System.out.print(\请输入存款金额:\); money = input.nextDouble(); ac.deposit(money); break; case 2:

System.out.print(\请输入取款金额:\); money = input.nextDouble(); ac.take(money); break; default:

System.out.println(\请输入正确的选择! }

}while(choice != 0);

System.out.println(\谢谢使用!\); } }

); \

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4