编程语言
首页 > 编程语言> > Java模拟ATM机系统

Java模拟ATM机系统

作者:互联网

import java.util.Scanner;

public class k29 {
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("\t模拟自动取款机系统");
System.out.println("==============================");
int cardid=123456789,pwd=123456;
double price=5000,ck=0,qk=0,zz=0;
int cardid2=987654321;
double price2=1000;
System.out.println("请插卡(录入卡号)");
int id=in.nextInt();
if(cardid==id){
System.out.println("请输入密码:");
int pwd2=in.nextInt();
if(pwd==pwd2){
System.out.println("1.存款|2.取款|3.查询余额|4.转账|5.修改密码|6.退卡");
System.out.println("请输入操作编号:");
int n=in.nextInt();
switch(n){
case 1:
System.out.println("请输入存款金额:");
ck=in.nextDouble();
price=price+ck;
System.out.println("存款成功!现在的余额为:"+price);
break;
case 2:
System.out.println("请输入取款金额:");
qk=in.nextDouble();
if(qk<+price){
price=price-qk;
System.out.println("请取走"+qk+"元,现在余额为:"+price);
}
else{
System.out.println("取款金额过大,余额不足!");
}
break;
case 3:
System.out.println("您当前卡内余额为:"+price);
break;
case 4:
System.out.println("请输入对方的卡号:");
int userid=in.nextInt();
if(userid==cardid2){
System.out.println("请输入转账金额:");
zz=in.nextDouble();
if(zz<=price){
price=price-zz;
price2=price2+zz;
System.out.println("转账成功!您当前余额为:"+price);
}
else{
System.out.println("转账失败,余额不足!");
}
}
else{
System.out.println("卡号错误!");
}
break;
case 5:
System.out.println("请输入原始密码:");
int pwd3=in.nextInt();
if(pwd3==pwd){
System.out.println("请输入新密码:");
pwd=in.nextInt();
System.out.println("密码修改成功!");
}
else{
System.out.println("原始密码有误,无法修改!");
}
break;
case 6:
System.out.println("***请取卡***");
System.out.println("谢谢使用本系统进行自助取款");
return;
default:
System.out.println("操作号录入有误,请重新输入!");
}
}
else{
System.out.println("密码有误!");
}
}

}

}

标签:机系统,Java,int,price,ATM,System,nextInt,println,out
来源: https://www.cnblogs.com/wobushiwr/p/16153947.html