[Java] 纯文本查看 复制代码 package pers.luochen.This.lianxi01;
import java.util.Scanner;
public class CustomerTest {
public static void main(String[] args) {
//java.util.Scanner s = new java.util.Scanner(System.in);
Scanner s = new Scanner(System.in);
System.out.print("请输入您的姓名:");
//待用户输入姓名
String name = s.next();
System.out.print("请输入您的账户:");
//待用户输入账户
int account = s.nextInt();
System.out.println("账户信息:");
Account account1 = new Account();
account1.setID(account);
Account account2 = new Account();
account2.setName(name);
Account w = new Account();
do {
System.out.print("请选择本次操作:");
System.out.println("\033[31;4m" + "(1是存款,2是取款,0是退出)" + "\033[0m");
int deposit = s.nextInt();
if (deposit == 1) {
System.out.print("请输入存款数额:");
int deposit1 = s.nextInt();
w.deposit(deposit1);
} else if (deposit == 2) {
System.out.print("请输入取款数额:");
int take = s.nextInt();
w.take(take);
} else if (deposit == 0) {
System.exit(0);
s.close();
} else {
System.out.println("本次操作不正确");
}
w.getBalance();
} while (true);
}
}
----------------------------------------------------------------------------------------------------------------------------
[Java] 纯文本查看 复制代码 public void take(int number1) {
if (balance < number1) {
System.out.println("你的余额不足,取钱失败");
}
if (balance >= number1) {
System.out.println("本次操作成功,取出:" + number1 + "元");
//System.out.println("余额:"+ balance - number1);
}
}
下面这个是旧代码
小白写的简单“存取款”程序。(代码不够完善,大佬指点指点)
https://www.52pojie.cn/thread-1449983-1-1.html
(出处: 吾爱破解论坛)
|