import javax.swing.JOptionPane;
public class atm {
public static void main(String[] args) {
JOptionPane.showMessageDialog(null, "欢迎光临,英国瑞士银行");
boolean islogin = login1();
while (true) {
if (islogin == true) {
String s = JOptionPane.showInputDialog(null,
"1、存款\n2、取款\n3、查询余额\n4、退卡");
int x = Integer.parseInt(s);
switch (x) {
case 1:
savemoney1();
break;
case 2:
getmoney1();
break;
case 3:
showmoney1();
break;
case 4:
JOptionPane.showMessageDialog(null, "请取走你的卡片");
System.exit(0);
break;
default:
JOptionPane.showMessageDialog(null, "请输入1-4");
break;
}
}
}
}
public static int money = 5000;
public static void savemoney1() {
String s = JOptionPane.showInputDialog(null, "输入存款金额");
money += Integer.parseInt(s);
int x = JOptionPane.showConfirmDialog(null, "是否显示余额");
if (x == 0) {
showmoney1();
}
}
public static void getmoney1() {
String s = JOptionPane.showInputDialog(null, "请输入取款金额");
int x = Integer.parseInt(s);
if (x > money) {
JOptionPane.showMessageDialog(null, "余额不足");
} else {
money -= x;
int n = JOptionPane.showConfirmDialog(null, "是否显示余额");
if (n == 0) {
showmoney1();
}
}
}
public static void showmoney1() {
JOptionPane.showMessageDialog(null, "余额:" + money);
}
public static boolean login1() {
for (int i = 0; i < 3; i++) {
String s = JOptionPane.showInputDialog(null, "请输入卡号");
int card = Integer.parseInt(s);
String n = JOptionPane.showInputDialog(null, "请输入密码");
int pwd = Integer.parseInt(n);
if (card == 123 && pwd == 456) {
return true;
} else {
JOptionPane.showMessageDialog(null, "卡号或密码错误");
}
}
JOptionPane.showMessageDialog(null, "卡号和密码输入错误超过3次,请联系发卡行");
System.exit(0);
return false;
}
}
public class atm {
public static void main(String[] args) {
JOptionPane.showMessageDialog(null, "欢迎光临,英国瑞士银行");
boolean islogin = login1();
while (true) {
if (islogin == true) {
String s = JOptionPane.showInputDialog(null,
"1、存款\n2、取款\n3、查询余额\n4、退卡");
int x = Integer.parseInt(s);
switch (x) {
case 1:
savemoney1();
break;
case 2:
getmoney1();
break;
case 3:
showmoney1();
break;
case 4:
JOptionPane.showMessageDialog(null, "请取走你的卡片");
System.exit(0);
break;
default:
JOptionPane.showMessageDialog(null, "请输入1-4");
break;
}
}
}
}
public static int money = 5000;
public static void savemoney1() {
String s = JOptionPane.showInputDialog(null, "输入存款金额");
money += Integer.parseInt(s);
int x = JOptionPane.showConfirmDialog(null, "是否显示余额");
if (x == 0) {
showmoney1();
}
}
public static void getmoney1() {
String s = JOptionPane.showInputDialog(null, "请输入取款金额");
int x = Integer.parseInt(s);
if (x > money) {
JOptionPane.showMessageDialog(null, "余额不足");
} else {
money -= x;
int n = JOptionPane.showConfirmDialog(null, "是否显示余额");
if (n == 0) {
showmoney1();
}
}
}
public static void showmoney1() {
JOptionPane.showMessageDialog(null, "余额:" + money);
}
public static boolean login1() {
for (int i = 0; i < 3; i++) {
String s = JOptionPane.showInputDialog(null, "请输入卡号");
int card = Integer.parseInt(s);
String n = JOptionPane.showInputDialog(null, "请输入密码");
int pwd = Integer.parseInt(n);
if (card == 123 && pwd == 456) {
return true;
} else {
JOptionPane.showMessageDialog(null, "卡号或密码错误");
}
}
JOptionPane.showMessageDialog(null, "卡号和密码输入错误超过3次,请联系发卡行");
System.exit(0);
return false;
}
}