java银行工作代码 银行java开发怎么样

用java语言编写一个小型的银行系统代码private int balance = 0;
privateString username = "A";
privateString password = "B";
public void bank() {
Scanner scan = new Scanner(System.in);
Stringtemp;
while (true) {
System.out.println("输入账号:");
if (scan.hasNext()) {
temp = scan.next();
if (temp.equals(username)) {
break;
} else {
System.out.println("输入错误");
}
}
}
while (true) {
System.out.println("输入密码:");
if (scan.hasNext()) {
temp = scan.next();
if (temp.equals(password)) {
break;
} else {
System.out.println("输入错误");
}
}
}
System.out.println("登录成功");
while (true) {
System.out.println("输入操作:");
if (scan.hasNext()) {
temp = scan.next();
switch (temp) {
case "存款":
int x = 0;
while (true) {
System.out.println("输入存款金额:");
if (scan.hasNextInt()) {
x = scan.nextInt();
break;
} else {
System.out.println("输入错误");
scan.next();
}
}
balance += x;
break;
case "取款":
int y = 0;
while (true) {
System.out.println("输入取款金额:");
if (scan.hasNextInt()) {
y = scan.nextInt();
if (balancey) {
System.out.println("余额不足");
continue;
}
break;
} else {
System.out.println("输入错误");
scan.next();
}
}
balance -= y;
break;
case "余额":
System.out.println("余额:" + balance);
break;
case "终止":
System.exit(0);
default:
System.out.println("未知操作");
}
}
}
JAVA 简单银行系统的代码import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class AccountDemo {
public static double MONEY = 0;// 初始化金额是100元 。
public static void main(String[] args) {
final String USER_NAME = "zhangsan";// 用户名
final String PASSWORD = "123456";// 密码
while (true) {
System.out.print("请输入用户名:");
String user_name = getString();
System.out.print("请输入密码:");
String password = getString();
if (user_name != nulluser_name.equals(USER_NAME)
password != nullpassword.equals(PASSWORD)) {
System.out.println("登陆成功!你要干什么?");
while (true) {
System.out.println("1:存款");
System.out.println("2:取款");
System.out.println("3:查询余额");
System.out.println("q:退出程序");
System.out.print("请选择:");
String userIn = getString();
int in = 0;
if (userIn != nulluserIn.equals("1")) {
in = Integer.parseInt(userIn);
} else if (userIn != nulluserIn.equals("2")) {
in = Integer.parseInt(userIn);
} else if (userIn != nulluserIn.equals("3")) {
in = Integer.parseInt(userIn);
} else if (userIn != null
userIn.trim().toUpperCase().equals("Q")) {
in = 4;
} else {
System.out.println("你输入的指令不正确!请重新输入 。");
continue;
}
switch (in) {
case 1:
double add_money = 0;
while (true) {
System.out.print("请输入你要存入的金额:");
try {
add_money = Double.parseDouble(getString());
} catch (Exception e) {
System.out.println("金额输入不正确!");
continue;
}
break;
}
MONEY += add_money;
System.out.println("存入的金额是" + add_money
+ "\r\n请选择你要的操作:");
break;
case 2:
double money = 0;
while (true) {
System.out.print("请输入你要取出的金额:");
try {
money = Double.parseDouble(getString());

推荐阅读