package DiSan;
import java.util.Scanner;
public class DiS {
private static double money = 150000;
private static double maxmoney = 200000;
private static double smoney = 20000;
public static void main(String[] args) {
int user = 123456;
int passWord = 123;
login(user, passWord);
}
public static void login(int user, int passWord) {
for (int m = 1; m < 4; m++) {
System.out.println("请输入账户:");
Scanner userSc = new Scanner(System.in);
int userIn = userSc.nextInt();
System.out.println("请输入密码:");
Scanner passWordSc = new Scanner(System.in);
int passWordIn = passWordSc.nextInt();
if (user == userIn && passWord == passWordIn) {
System.out.println("登录成功~");
page();
} else {
System.out.println("账户或密码有误,请重新输入~");
}
}
System.out.println("您已经次数超过限制,请联系相关银行~");
System.exit(0);
}
public static void page() {
System.out.println("*************************************");
System.out.println("**********欢迎使用奥特曼ATM机***********");
System.out.println("*************************************");
System.out.println("1:查询 2:取款 3:存款 4:退出");
Scanner chooseSC = new Scanner(System.in);
int x = chooseSC.nextInt();
if (x == 1) {
System.out.println("你的余额为: " + smoney);
page();
}
if (x == 2) {
System.out.println("请输入你的取款金额: ");
Scanner hahSC = new Scanner(System.in);
double yue = hahSC.nextDouble();
if (yue == 0) {
System.out.println("取款金额不能等于0,请重新输入");
page();
} else if (yue % 100 != 0) {
System.out.println("取款金额需是100的倍数,请重新输入");
page();
} else if (yue < 0) {
System.out.println("取款金额不能为负,请重新输入");
page();
} else if (yue > smoney) {
System.out.println("您的余额不足,请重新输入");
page();
} else if (yue > money) {
System.out.println("取款机余额不足,请重新输入");
page();
} else {
smoney = smoney - yue;
}
page();
}
if (x == 3) {
System.out.println("请放入现金");
Scanner xuxuSC = new Scanner(System.in);
double pao = xuxuSC.nextDouble();
if (pao + money > maxmoney) {
System.out.println("数额过高 请重新输入");
} else {
smoney = pao + smoney;
}
page();
}
if (x == 4) {
System.out.println("谢谢使用,再见");
System.exit(0);
} else{
System.out.println("输入有误!");
page();
}
}
}
原文:http://www.cnblogs.com/oushiyang/p/5300055.html