import java.util.Scanner;
public class ZH {
private String zh;//账户
private String password;//密码
private String openTime;//开户时间
private String sfz;//身份证号
private double je;//存款金额
public String getZh() {
return zh;
}
public void setZh(String zh) {
this.zh = zh;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getOpenTime() {
return openTime;
}
public void setOpenTime(String openTime) {
this.openTime = openTime;
}
public String getSfz() {
return sfz;
}
public void setSfz(String sfz) {
this.sfz = sfz;
}
public double getJe() {
return je;
}
public void setJe(double je) {
this.je = je;
}
//存款方法
public void ck(double je){
this.je=this.je+je;//存入的金额加上原有的金额
}
//取款方法
public void qk(double je){
if(je>this.je){//取款金额大于余额
System.out.println("存款余额不足");
}else{
this.je=this.je-je;//原有的金额减去取出的金额
}
}
public static void main(String[] args) {
ZH zh = new ZH();//初始化一个账户信息
zh.setJe(10000.0);//向zh账户添加余额
zh.setOpenTime("2013.12.3");//向zh账户添加开发时间
zh.setPassword("123456");//向zh账户添加密码
zh.setSfz("123456789");//向zh账户添加身份证
zh.setZh("zhangsan");//向zh账户添加账号
System.out.println("欢迎光临模拟银行");
Scanner scan = new Scanner(System.in);
int count=0;//记录输入错误的次数
while(1==1){//循环
System.out.println("请输入账号");
String zhm=scan.next();
System.out.println("请输入密码");
String mm=scan.next();
if(zhm.equals(zh.getZh()) && mm.equals(zh.getPassword())){//输入的信息与zh账户信息的密码和账号一致
while(1==1){
System.out.println("当前余额为:"+zh.getJe()+"元。请选择操作:1.存款;2.取款;3.退出(只能输入数字)");
String cz=scan.next();
switch (Integer.parseInt(cz)) {
case 1:
System.out.println("请输入存款金额(输入小数)");
double ckje=scan.nextDouble();
zh.ck(ckje);
System.out.println("实施存款:"+ckje+"元,当前余额为"+zh.getJe()+"元");
break;
case 2:
System.out.println("请输入取款金额(输入小数)");
double qkje=scan.nextDouble();
zh.qk(qkje);
System.out.println("实施取款:"+qkje+"元,当前余额为"+zh.getJe()+"元");
break;
case 3:
break;
default:
System.out.println("暂无此功能");//输入1或者2、3以外的操作
break;
}
if("3".equals(cz)){
break;
}
}
System.out.println("退出操作");
break;
}else{
if(count>=3){
System.out.println("已输入错误三次,账号被锁");
break;//结束循环
}else{
System.out.println("账号或密码错误,请重新输入");
count++;//错误一次count+1
continue;//进入下次循环
}
}
}
}
}