package demo;
import javautilScanner;
public class Test3 {
public static void main(String[] args) {
Scanner scanner =new Scanner(Systemin);
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)){
Systemoutprintln("欢迎光临");
while(true){
Systemoutprintln("请选择您的 *** 作 1 取钱 2 存钱 3 转账 4 查询 5 退出 ");
int n = scannernextInt();
if(n==1){//取钱
int getter = scannernextInt();
if(getter>=0){
if(getter<=5000){
if(getter<=money){
money-=getter;
}else{
Systemoutprintln("余额不足");
}
}else{
Systemoutprintln("单笔只能取5000及以下");
}
}else{
Systemoutprintln("银行不到给");
}
}else if(n==2){//存钱
Systemoutprintln("请输入金额");
int save = scannernextInt();
if(save>=0){
money+=save;
}
}else if(n==3){//转账
Systemoutprintln("请输入目标账户");
String target = scannernext();
if(targetequals(targetName)){
Systemoutprintln("请输入金额");
int getter = scannernextInt();
if(getter>=0){
if(getter<=5000){
if(getter<=money){
money-=getter;
targetMoney+=getter;
}else{
Systemoutprintln("余额不足");
}
}else{
Systemoutprintln("单笔只能取5000及以下");
}
}else{
Systemoutprintln("银行不到给");
}
}
}else if(n==4){//查询
Systemoutprintln(money);
}else if(n==5){//退出
Systemexit(0);
}else{
Systemoutprintln("没有该项服务");
}
}
}else{
cnt--;
Systemoutprintln("输入错误,您还有"+cnt+"次机会");
username=null;
password=null;
if(cnt<=0){
Systemoutprintln("对不起,您的账号被冻结,请到最近的营业厅解除冻结");
Systemexit(0);
}
}
}else{
Systemoutprintln("请输入您的账号");
username = scannernext();
Systemoutprintln("请输入您的密码");
password = scannernext();
}
}
}
}
package arraylist;
import javautilScanner;
public class AtmDemo
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
Scanner sc = new Scanner(Systemin);
Boolean flag = true;
int times = 0;
while(flag){
times++;
if(times == 4){
Systemoutprintln("密码错误,请取卡");
break;
}
Systemoutprintln("请输入你的密码");
String password = scnext();
if(passwordequals("111111")){
Boolean moneyflag = true;
while(moneyflag){
Systemoutprintln("请输入金额");
int number = scnextInt();
if(number >= 0 && number <= 1000 && number % 100 == 0){
Systemoutprintln("用户取了" + number + "元。交易完成");
moneyflag = false;
}else{
Systemoutprintln("请重新输入金额");
}
}
break;
}else{
continue;
}
}
}
}
以上就是关于Java编程实现程序用于模拟ATM取款机。全部的内容,包括:Java编程实现程序用于模拟ATM取款机。、java atm机代码、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)