package ATM;
import java.util.Scanner;
publicclassAccountManager1 {
private static Account[] acc=new Account[5];
private static int mf=-1;
private static int sf=-1;
public AccountManager1() {
for(int i=0;i<5;i++) {
acc[i]=new Account();
}
acc[0]=new Account("20194021","marongrong","000001",1000);
acc[1]=new Account("20190002","zhanghong","000002",2000);
acc[2]=new Account("20190003","wanggang","000003",3000);
acc[3]=new Account("20190004","sunli","000004",4000);
acc[4]=new Account("20190005","zhaoqiang","000005",5000);
}//打印出主界面
public static void show1() {
System.out.println("*****************************************");
System.out.println("欢迎使用中国工商银行自动柜员系统 ");
System.out.println("*****************************************");
System.out.println("请输入您的账号: ");
System.out.println("*****************************************");
}
public static void InputID() {
int flag=0;
Scanner con=new Scanner(System.in);String accountid=con.next();
for(int i=0;i<5;i++) {
if(accountid.equals(acc[i].getaccountID())) {
flag=1;
mf=i;
break;
}
}
if(flag==0) System.out.println("该卡不是工行卡!");
if(flag==1) show2();
}//打印出输入密码界面
public static void show2() {
System.out.println("*****************************************");
System.out.println("欢迎"+acc[mf].getaccountname()+"使用中国工商银行自动柜员系统 ");
System.out.println("*****************************************");
System.out.println("请输入您的密码: ");
System.out.println("*****************************************");
}
public static void Inputpassword() {
int m=0;
int f=2;
Scanner con=new Scanner(System.in);
do {String accountpass=con.next();
if(accountpass.compareTo(acc[mf].getaccountpassword())==0) {
f=1;
}
if(f==2) {System.out.println("密码录入错误!");show2();}
if(f==1) {System.out.println("密码输入成功!");show3();break;}
m++;
}while(m<3);
if(m==3)System.out.println("该账号三次录入密码错误,该卡已被系统没收,请与工商及时联系处理");
}//打印出功能界面
public static void show3() {
System.out.println("*****************************************");
System.out.println("欢迎"+acc[mf].getaccountname()+"使用中国工商银行自动柜员系统 ");
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("*****************************************");
}//存款
public static void show4() {
System.out.println("*****************************************");
System.out.println("欢迎"+acc[mf].getaccountname()+"使用中国工商银行自动柜员系统 ");
System.out.println("*****************************************");
System.out.println("请输入存款金额: ");
System.out.println("*****************************************");
}
public static void show5() {
System.out.println("*****************************************");
System.out.println("欢迎"+acc[mf].getaccountname()+"使用中国工商银行自动柜员系统 ");
System.out.println("*****************************************");
System.out.println("当前帐户存款成功! ");
System.out.println("当前帐户余额为:"+acc[mf].getaccountbalance());
System.out.println("*****************************************");
}
public static void cunkuan() {
Scanner con=new Scanner(System.in);
int money=con.nextInt();
if(money!=(int)money) {
System.out.println("输入金额有误!");
}
else {
acc[mf].setaccountbalance(acc[mf].getaccountbalance()+money);
show5();
}
}//取款
public static void show6() {
System.out.println("*****************************************");
System.out.println("欢迎"+acc[mf].getaccountname()+"使用中国工商银行自动柜员系统 ");
System.out.println("*****************************************");
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、退卡 ");
System.out.println("9、返回 ");
System.out.println("*****************************************");
}
public static void show7() {
System.out.println("*****************************************");
System.out.println("欢迎"+acc[mf].getaccountname()+"使用中国工商银行自动柜员系统 ");
System.out.println("*****************************************");
System.out.println("请输入取款金额: ");
System.out.println("*****************************************");
}
public static void show8() {
System.out.println("*****************************************");
System.out.println("欢迎"+acc[mf].getaccountname()+"使用中国工商银行自动柜员系统 ");
System.out.println("*****************************************");
System.out.println("当前帐户账户款成功! ");
System.out.println("当前帐户余额为:"+acc[mf].getaccountbalance());
System.out.println("*****************************************");
}
public static void qukuan() {
Scanner con=new Scanner(System.in);
System.out.println("请选择:");
int p=con.nextInt();
if(p==1) {if(acc[mf].getaccountbalance()<100)System.out.println("账户余额不足");
else {
acc[mf].setaccountbalance(acc[mf].getaccountbalance()-100);
show8();
}}
else if(p==2) {if(acc[mf].getaccountbalance()<500)System.out.println("账户余额不足");
else {
acc[mf].setaccountbalance(acc[mf].getaccountbalance()-500);
show8();
}}
else if(p==3) {if(acc[mf].getaccountbalance()<1000)System.out.println("账户余额不足");
else {
acc[mf].setaccountbalance(acc[mf].getaccountbalance()-1000);
show8();
}}
else if(p==4) {if(acc[mf].getaccountbalance()<1500)System.out.println("账户余额不足");
else {
acc[mf].setaccountbalance(acc[mf].getaccountbalance()-1500);
show8();
}}
else if(p==5) {if(acc[mf].getaccountbalance()<2000)System.out.println("账户余额不足");
else {
acc[mf].setaccountbalance(acc[mf].getaccountbalance()-2000);
show8();
}}
else if(p==6) {if(acc[mf].getaccountbalance()<5000)System.out.println("账户余额不足");
else {
acc[mf].setaccountbalance(acc[mf].getaccountbalance()-5000);
show8();
}}
else if(p==7) {
show7();
int qu=con.nextInt();
if(acc[mf].getaccountbalance()
else {
acc[mf].setaccountbalance(acc[mf].getaccountbalance()-qu);
show8();
}
}
else if(p==8) {
show1();
InputID();
Inputpassword();
int n;
System.out.println("请输入序号:");
n=con.nextInt();
switch(n) {
case1:{
show4();
cunkuan();
show5();
break;
}
case2:{
show6();
qukuan();
break;
}
case3:{
show9();
break;
}
case4:{
xiugaimima();break;
}
case5:{
chaxun();
break;
}
}
}
else if(p==9) {show3();
System.out.println("请输入序号:");
int n=con.nextInt();
switch(n) {
case1:{
show4();
cunkuan();
show5();
break;
}
case2:{
show6();
qukuan();
break;
}
case3:{
show9();
break;
}
case4:{
xiugaimima();break;
}
case5:{
chaxun();
break;
}
}
}
}//转账
public static void show9() {
System.out.println("*****************************************");
System.out.println("欢迎"+acc[mf].getaccountname()+"使用中国工商银行自动柜员系统 ");
System.out.println("*****************************************");
System.out.println("请输入转账账户: ");
System.out.println("*****************************************");
}
public static void show10() {
System.out.println("*****************************************");
System.out.println("欢迎"+acc[mf].getaccountname()+"使用中国工商银行自动柜员系统 ");
System.out.println("*****************************************");
System.out.println("请输入转账金额: ");
System.out.println("*****************************************");
}
public static void zhuazhang1() {
int flag=0;
Scanner con=new Scanner(System.in);String str=con.next();
for(int i=0;i<5;i++) {
if(str.equals(acc[i].getaccountID())) {
flag=1;
sf=i;
break;
}
}
if(flag==0) System.out.println("该账户不存在!");
if(flag==1)show10();
}
public static void zhuanzhang2() {
Scanner con=new Scanner(System.in);
int mo=con.nextInt();
if(acc[sf].getaccountbalance()
else {
System.out.println("*****************************************");
System.out.println("欢迎"+acc[mf].getaccountname()+"使用中国工商银行自动柜员系统 ");
System.out.println("*****************************************");
System.out.println("请确认是否向"+acc[sf].getaccountname()+"转账"+mo+"元(Y/N)");
System.out.println("*****************************************");
String a=con.next();
if(a.equals("N")) {
show3();
System.out.println("请输入序号:");
int n=con.nextInt();
switch(n) {
case1:{
show4();
cunkuan();
show5();
break;
}
case2:{
show6();
qukuan();
break;
}
case3:{
show9();
break;
}
case4:{
xiugaimima();break;
}
case5:{
chaxun();
break;
}
}
}
if(a.equals("Y")) {
System.out.println("*****************************************");
System.out.println("欢迎"+acc[mf].getaccountname()+"使用中国工商银行自动柜员系统 ");
System.out.println("*****************************************");
System.out.println("当前帐户向"+acc[sf].getaccountname()+"成功转账"+mo+"元");
System.out.println("当前帐户余额为:"+(acc[sf].getaccountbalance()-mo)+"元");
System.out.println("*****************************************");
}
}
}//修改密码
public static void xiugaimima() {
Scanner con=new Scanner(System.in);
System.out.println("请输入新密码:");
String mima=con.next();
acc[mf].setaccountpassword(mima);
System.out.println("修改密码成功!");
}//查询余额
public static void chaxun() {
System.out.println("余额为:"+acc[mf].getaccountbalance());
}//输入q返回登录账户界面
public static void tuichu() {
Scanner con=new Scanner(System.in);
if(con.next().equals("q")) {
show1();
InputID();
Inputpassword();
int n;
System.out.println("请输入序号:");
n=con.nextInt();
switch(n) {
case1:{
show4();
cunkuan();
show5();
break;
}
case2:{
show6();
qukuan();
break;
}
case3:{
show9();
break;
}
case4:{
xiugaimima();break;
}
case5:{
chaxun();
break;
}
}
}
}
public static void main(String[] args) {
Scanner con=new Scanner(System.in);
AccountManager1 atm=new AccountManager1();
show1();
InputID();
Inputpassword();
int n;
System.out.println("请输入序号:");
n=con.nextInt();
switch(n) {
case1:{
show4();
cunkuan();
tuichu();
break;
}
case2:{
show6();
qukuan();
break;
}
case3:{
show9();
zhuazhang1();
zhuanzhang2();
tuichu();
break;
}
case4:{
xiugaimima();
tuichu();
break;
}
case5:{
chaxun();
tuichu();
break;
}
}
}
}