银行取款系统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银行存取款代码问题,做得好我就追加悬赏您好银行取款系统Java代码,
创建状态
使用new运算符创建一个线程后银行取款系统Java代码,该线程仅仅是一个空对象,系统没有分配资源,称该线程处于创建状态(new thread)
可运行状态
使用start()方法启动一个线程后 , 系统为该线程分配银行取款系统Java代码了除CPU外银行取款系统Java代码的所需资源,使该线程处于可运行状态(Runnable)
运行中状态
Java运行系统通过调度选中一个Runnable银行取款系统Java代码的线程,使其占有CPU并转为运行中状态(Running) 。此时,系统真正执行线程的run()方法 。
package pack.java.thread.atm;
/**
* 账户类;
* @author Administrator
*
*/
public class Account {
private String name;//用户名;
private int value;//账户余额;
/**
* 存入金额;
* @param monery
*/
public void putMonery(int monery){
this.value = https://www.04ip.com/post/this.value + monery;
}
/**
* 取出金额;
* @param monery
* @return 金额;
*/
public int getMonery(int monery){
//判断是否账户余额是否大于 要取出的钱;
if(this.valuemonery ){
this.value = https://www.04ip.com/post/this.value - monery;
}else{
monery = this.value;//账户余额不够时,则取出,所有的账户余额的金额.
this.value = https://www.04ip.com/post/0;
}
//返回取出的钱;
return monery;
}
/**
* 查询余额;
* @return 返回账户余额;
*/
public int search(){
return this.value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = https://www.04ip.com/post/value;
}
}
急急急~~求JAVA中用方法写出一个银行ATM取款机的代码怎么写?。?/h2>public class Card {

推荐阅读