package Test; import java.util.*; class Acount{ String kahao; String name; String date; String mima; double yue ; Scanner input = new Scanner(System.in); public Acount(String k,String n,String d,String m,double y) { kahao = k; name = n; date = d; mima = m; yue = y; } public void setkahao(String k){ kahao = k; } public String getkahao() { return kahao; } public void setyue(double y){ yue = y; } public double getyue() { return yue; } public void setname(String n){ name = n; } public String getname() { return name; } public void setdate(String d){ date = d; } public String getdate() { return date; } public void setmima(String m){ mima = m; } public String getmima() { return mima; } public void qukuan(){ int m; for(m=0;;m++){ System.out.println("请选择取款金额:"); System.out.println("1、100元"); System.out.println("2、500元"); System.out.println("3、1000元"); System.out.println("4、1500元"); System.out.println("5、2000元"); System.out.println("6、5000元"); System.out.println("7、其他金额"); System.out.println("8、退卡"); int a = input.nextInt(); if(a == 1) { yue = yue - 100; } if(a == 2) { yue = yue - 500; } if(a == 3) { yue = yue - 1000; } if(a == 4) { yue = yue - 1500; } if(a == 5) { yue = yue - 2000; } if(a == 6) { yue = yue - 5000; } if(a == 7) { System.out.println("请输入取款金额:"); int b = input.nextInt(); yue = yue - b; } if(a == 8) { break; } } } public void zhuanzhang(){ System.out.println("请输入转账行号:"); String n = input.next(); if(n.equals(getkahao())) { System.out.println("请输入转账金额:"); int j = input.nextInt(); yue = yue + j; } else { System.out.println("没有此人!"); System.exit(0); } } public void xiugaimima() { System.out.println("请输入要修改的行号:"); String n = input.next(); if(n.equals(getkahao())) { System.out.println("请输入新密码:"); String m = input.next(); mima= m; System.out.println("修改成功"); System.exit(0); } } public void chaxun() { System.out.println("请输入查询的行号:"); String m = input.next(); if(m.equals(getkahao())) { System.out.println("余额为" + getyue()); } else System.out.println("不存在"); } public void cunkuan(){ System.out.println("请输入金额:"); double b = input.nextDouble(); yue = yue+b; } public void denglu(){ System.out.println("请输入卡号:"); String n = input.next(); System.out.println("请输入密码:"); String m = input.next(); if(m.equals(getmima())&&n.equals(getkahao())) { System.out.println("登陆成功"); int t; for(t=0;;t++){ System.out.println("请选择:"); System.out.println("1、取款"); System.out.println("2、转账"); System.out.println("3、存款"); System.out.println("4、查询余额"); System.out.println("5、修改密码"); System.out.println("6、退卡"); int a = input.nextInt(); if(a == 1) { qukuan(); } if(a == 2) { zhuanzhang(); } if(a == 3) { cunkuan(); } if(a == 4) { chaxun(); } if(a == 5) { xiugaimima(); } if(a == 6) { break; } } } else { System.out.println("密码错误!"); System.exit(0); } } } public class ATMShow { public static void main(String[] args){ Acount A = new Acount("11111","HYY","20161","123456",1000); A.denglu(); } }
截图:
时间: 2024-11-23 00:45:14