import java.util.Scanner
public class Test3 {
public static void main(String[] args) {
Scanner scanner =new Scanner(System.in)
int cnt=3
String username = null
String password = null
double money = 1000
String targetName = "admin33"
double targetMoney = 1000
while(true){
if(username!=null&&password!=null){
if("admin".equals(username) &&"123".equals(password)){
System.out.println("欢迎光临")
while(true){
System.out.println("请选择您的 *** 作 1 取钱 2 存钱 3 转账 4 查询 5 退出 ")
int n = scanner.nextInt()
if(n==1){//取钱
System.out.println("请输入金额")
int getter = scanner.nextInt()
if(getter>=0){
if(getter<=5000){
if(getter<=money){
money-=getter
}else{
System.out.println("余额不足")
}
}else{
System.out.println("单笔只能取5000及以下")
}
}else{
System.out.println("银行不到给")
}
}else if(n==2){//存钱
System.out.println("请输入金额")
int save = scanner.nextInt()
if(save>=0){
money+=save
}
}else if(n==3){//转账
System.out.println("请输入目标账户")
String target = scanner.next()
if(target.equals(targetName)){
System.out.println("请输入金额")
int getter = scanner.nextInt()
if(getter>=0){
if(getter<=5000){
if(getter<=money){
money-=getter
targetMoney+=getter
}else{
System.out.println("余额不足")
}
}else{
System.out.println("单笔只能取5000及以下")
}
}else{
System.out.println("银行不到给")
}
}
}else if(n==4){//查询
System.out.println(money)
}else if(n==5){//退出
System.exit(0)
}else{
System.out.println("没有该项服务")
}
}
}else{
cnt--
System.out.println("输入错误,您还有"+cnt+"次机会")
username=null
password=null
if(cnt<=0){
System.out.println("对不起,您的账号被冻结,请到最近的营业厅解除冻结")
System.exit(0)
}
}
}else{
System.out.println("请输入您的账号")
username = scanner.next()
System.out.println("请输入您的密码")
password = scanner.next()
}
}
}
}
/** * @author admin * 该程序的功能为实现模拟银行ATM自动取款机提款,查询等功能. */ import Java.io.*/*该类为实现客户信息及部分功能*/ class Account { private String code =null//xyk号 private String name =null//客户姓名 private String password=null//客户密码 private double money =0.0//卡里金额 public Account(String code,String name,String password,double money) { this.code=codethis.name=namethis.password=passwordthis.money=money} protected String get_Code() { return code} protected String get_Name() { return name} protected String get_Password() { return password} public double get_Money() { return money} /*得到剩余的钱的数目*/ protected void set_Balance(double mon) { money -= mon} } /**********实现具体取款机功能*********/ class ATM { Account act// private String name// private String pwdpublic ATM() { act=new Account("000000","Devil","123456",50000)} /***********欢迎界面***********/ protected void Welcome() { String str="---------------------------------"System.out.print(str "\n" "欢迎使用Angel模拟自动取款机程序.\n" str "\n")System.out.print(" 1.>取款." "\n" " 2.>查询信息." "\n" " 3.>密码设置." "\n" " 4.>退出系统." "\n")} /**********登陆系统**********/ protected void Load_Sys() throws Exception { String card,pwdint counter=0BufferedReader br=new BufferedReader(new InputStreamReader(System.in))do { System.out.println("请输入您的xyk号:")card=br.readLine()System.out.println("请输入您的密码:")pwd=br.readLine()if(!isRight(card,pwd)) { System.out.println("您的卡号或密码输入有误.")counter } else SysOpter()}while(counter<3)Lock_Sys()} 回复获取全部欢迎分享,转载请注明来源:内存溢出
评论列表(0条)