码迷,mamicode.com
首页 > 其他好文 > 详细

ATM

时间:2016-11-28 00:47:18      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:改密码   word   new   system   efault   [1]   密码   main   i++   

package com.classes;

import java.util.Scanner;

/*ATM机
* 登录
* 开户
* 修改密码
* 退出
*
* 查询
* 存款
* 取款(100,200,500,1000,2000)
* 转账
* 返回上级菜单
*/
public class Hanshu1124_1 {
public static void main(String[] args) {
String[] accout = new String[1];
int[] password = new int[1];
one(accout, password);
}

public static void one(String[] accout, int[] password) {
while (true) {
Scanner in = new Scanner(System.in);
System.out.println("请选择操作:a:开户 b:登录 c:修改密码 d:退卡");
String xuanze = in.next();
char chr = xuanze.toCharArray()[0];
switch (chr) {
case ‘a‘:
two(accout, password);
break;
case ‘b‘:
three(accout, password);
four();
break;
case ‘c‘:
five(password);
break;
case ‘d‘:
System.out.println("请取走你的银行卡");
System.exit(-1);
break;
default:
System.out.println("操作错误");
break;
}
}
}

public static void two(String[] accout, int[] password) {
Scanner in = new Scanner(System.in);
System.out.println("请输入你的开户账号");
String zhanghao = in.next();
accout[0] = zhanghao;
System.out.println("请输入密码");
int mima = in.nextInt();
password[0] = mima;
System.out.println("开户成功");
return;
}

public static void three(String[] accout, int[] password) {
while (true) {
Scanner in = new Scanner(System.in);
System.out.println("请输入账号");
String z = in.next();
System.out.println("请输入密码");
int q = in.nextInt();
for (int i = 0; i < accout.length; i++) {
if (z.equals(accout[0]) && q == password[0]) {
System.out.println("登录成功");
return;
} else {
System.out.println("登录失败,请重新登录");
one(accout, password);
}
}
}
}

public static void four() {
double money = 0;
while (true) {
Scanner in = new Scanner(System.in);
System.out.println("请选择操作:a:查询 b:存款 c:取款 d:转账 e:返回");
String xuanze = in.next();
char chr = xuanze.toCharArray()[0];
switch (chr) {
case ‘a‘:
System.out.println("你的账户余额:");
System.out.println(money);
break;
case ‘b‘:
Scanner input = new Scanner(System.in);
System.out.println("亲:如果你存款10万以上请到楼下银行");
System.out.println("请输入存款金额");
double cunkuan = in.nextInt();
System.out.println("存款成功!");
System.out.println("你的账户余额:");
money = cunkuan + money;
System.out.println(money);
break;
case ‘c‘:

Scanner inp = new Scanner(System.in);
System.out.println("请选择取款金额:");
System.out.println("a:100 b:200 c:500 d:1000 e:5000");
String qukuang = in.next();
char chr2 = qukuang.toCharArray()[0];
switch (chr2) {
case ‘a‘:
if (money < 100) {
System.out.println("你的账户余额不足");
} else {
money = money - 100;
System.out.println("你的账户余额为:");
System.out.println(money);
}
break;
case ‘b‘:
if (money < 200) {
System.out.println("你的账户余额不足");
} else {
money = money - 200;
System.out.println("你的账户余额为:");
System.out.println(money);
}
break;
case ‘c‘:
if (money < 500) {
System.out.println("你的账户余额不足");
} else {
money = money - 500;
System.out.println("你的账户余额为:");
System.out.println(money);
}
break;
case ‘d‘:
if (money < 1000) {
System.out.println("你的账户余额不足");
} else {
money = money - 1000;
System.out.println("你的账户余额为:");
System.out.println(money);
}
break;
case ‘e‘:
if (money < 5000) {
System.out.println("你的账户余额不足");
} else {
money = money - 5000;
System.out.println("你的账户余额为:");
System.out.println(money);
}
break;
default:
System.out.println("操作错误");
break;
}
break;
case ‘d‘:
Scanner inop = new Scanner(System.in);
System.out.println("请输入转入的账户:");
long qitazhanghu = inop.nextInt();
System.out.println("请输入转账金额:");
double zhuanzhangjine = inop.nextDouble();
if (money < zhuanzhangjine) {
System.out.println("你的账户余额不足");
} else {

System.out.println("亲:转账成功,打电话给你的小伙伴叫他取钱结媳妇吧!");
System.out.println("你的账户余额:");
money = money - zhuanzhangjine;
System.out.println(money);
}
break;
case ‘e‘:
return;
default:
System.out.println("操作错误");
break;
}
}
}

private static void five(int[] password) {
Scanner in = new Scanner(System.in);
System.out.println("请输入原始密码");
int shuru = in.nextInt();
int xinmima;
if (shuru == password[0]) {
System.out.println("原始密码验证通过");
System.out.println("请输入新密码");
xinmima = in.nextInt();
password[0] = xinmima;
System.out.println("密码修改成功");
System.out.println("你的新密码为" + password[0]);
return;
} else {
System.out.println("原始密码错误,请重新输入");
}

}
}

ATM

标签:改密码   word   new   system   efault   [1]   密码   main   i++   

原文地址:http://www.cnblogs.com/jianpanxia/p/6107617.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!