import java.util.Scanner;public class Mu216_3_35 {public static void main(String[] args) {//创建对象System.out.println("乔布斯:1 "+" \t "+"马斯克 : 2"+"\t" +" 巴菲特 : 3");Scanner d = new Scanner(System.in);System.out.print("请输入您想查的账号名对应的数字:");int x = d.nextInt();switch (x){case 1:Mu216_3_35 s = new Mu216_3_35("000111","乔布斯","2000-1-31","000000123456789000","130000000000000");s.setZhangHao("账号:"+"000123");System.out.println(s.getZhangHao());s.setName("储户姓名:"+"乔布斯");System.out.println(s.getName());s.setTime("开户时间:"+"2000年1月31日");System.out.println(s.getTime());s.setShenFen("身份证号码:"+"000000123456789000");System.out.println(s.getShenFen());s.setYue("存款余额:"+"130000000000000");System.out.println(s.getYue());s.Hu();//销户System.out.println("________________________");System.out.println("请选择操作:0 退出,1 存款,2 取款,3 余额查询,4 销户");while (true){Scanner sc = new Scanner(System.in);System.out.print("请输入相应的数字:");int i = sc.nextInt();switch (i){case 0:System.out.println("欢迎下次光临!");break;case 1:System.out.print("请输入存款金额:");double m = sc.nextDouble();s.cunKuan(m);break;case 2:System.out.print("请输入取款金额:");double m1 = sc.nextDouble();s.qvKuan(m1);break;case 3:s.cha();break;case 4:s.finalize();default:System.out.println("选择错误!");break;}}case 2:Mu216_3_35 s1 = new Mu216_3_35("000222","马斯克","2002-12-31","0000006531251000","130000000000000000");s1.setZhangHao("账号:"+"000222");System.out.println(s1.getZhangHao());s1.setName("储户姓名:"+"马斯克");System.out.println(s1.getName());s1.setTime("开户时间:"+"2002年12月31日");System.out.println(s1.getTime());s1.setShenFen("身份证号码:"+"0000006531251000");System.out.println(s1.getShenFen());s1.setYue("存款余额:"+"130000000000000000");System.out.println(s1.getYue());s1.Hu();//销户System.out.println("________________________");System.out.println("请选择操作:0 退出,1 存款,2 取款,3 余额查询,4 销户");while (true){Scanner sc = new Scanner(System.in);System.out.print("请输入相应的数字:");int i = sc.nextInt();switch (i){case 0:System.out.println("欢迎下次光临!");break;case 1:System.out.print("请输入存款金额:");double m = sc.nextDouble();s1.cunKuan(m);break;case 2:System.out.print("请输入取款金额:");double m1 = sc.nextDouble();s1.qvKuan(m1);break;case 3:s1.cha();break;case 4:s1.finalize();default:System.out.println("选择错误!");break;}}case 3:Mu216_3_35 s2 = new Mu216_3_35("000333","巴菲特","1999-1-1","0000001111111000","1830000000000000000");s2.setZhangHao("账号:"+"000333");System.out.println(s2.getZhangHao());s2.setName("储户姓名:"+"巴菲特");System.out.println(s2.getName());s2.setTime("开户时间:"+"1999年1月1日");System.out.println(s2.getTime());s2.setShenFen("身份证号码:"+"0000001111111000");System.out.println(s2.getShenFen());s2.setYue("存款余额:"+"1830000000000000000");System.out.println(s2.getYue());s2.Hu();//销户System.out.println("________________________");System.out.println("请选择操作:0 退出,1 存款,2 取款,3 余额查询,4 销户");while (true){Scanner sc = new Scanner(System.in);System.out.print("请输入相应的数字:");int i = sc.nextInt();switch (i){case 0:System.out.println("欢迎下次光临!");break;case 1:System.out.print("请输入存款金额:");double m = sc.nextDouble();s2.cunKuan(m);break;case 2:System.out.print("请输入取款金额:");double m1 = sc.nextDouble();s2.qvKuan(m1);break;case 3:s2.cha();break;case 4:s2.finalize();default:System.out.println("选择错误!");break;}}}}//账号private String zhangHao;//存储姓名private String name;//开户时间private String time;//身份证号码private String shenFen;//存款余额private String yue;//全参数构造方法public Mu216_3_35(String zhangHao,String name,String time,String shenFen,String yue){this.zhangHao = zhangHao;this.name = name;this.time = time;this.shenFen = shenFen;this.yue = yue;System.out.println("开户成功!\n" + this.name+"欢迎您!");}protected void finalize(){//账号注销System.out.println(this.name+"您的账号已注销!");}public void setZhangHao(String zhangHao){this.zhangHao = zhangHao;}public String getZhangHao(){return zhangHao;}public void setName(String name){this.name = name;}public String getName(){return name;}public void setTime(String time){this.time = time;}public String getTime(){return time;}public void setShenFen(String shenFen){this.shenFen = shenFen;}public String getShenFen(){return shenFen;}public void setYue(String yue){this.yue = yue;}public String getYue(){return yue;}//成员方法//存款public void cunKuan(double money){//存款if(money > 0){this.yue = this.yue + money;System.out.println(this.yue);System.out.println("存款成功!");}else{System.out.println("存款金额无效!存款失败!");}}//取款public void qvKuan(double money){//取款Double reminder = Double.parseDouble(yue);if(money <= reminder){reminder -= money;System.out.println(money);System.out.println("取款成功!");}else {System.out.println("余额不足!取款失败!");}this.yue = reminder.toString();}//查询public void cha(){System.out.println("余额为:" + this.yue);}//销户public void Hu(){System.out.println("您的账号信息为:\n账号\t\t\t开户时间\t\t\t\t\t身份证号\n" + this.zhangHao+"\t"+ this.time+"\t" + this.shenFen);}}
声明银行账号类Account 成员变量包括账号 储户姓名 开户时间 身份证号码 存款余额等账号信息 成员方法包括开户 存款 取款 查询(余额 明显) 销户等操作。