public class Account {
static double min = 10;
String account, name, address;
float balance = 0.0f;
public Account(String account, String name, String address, float balance) {
this.account = account;
this.name = name;
this.address = address;
this.balance = balance;
System.out.println("您賬戶中原有余額:" + balance);
}
public void deposit(float f) {
this.balance += f;
System.out.println("現存入:" + f);
System.out.println("當前余額:" + balance);
}
public void withdraw(float f) {
if (balance - f < min) {
System.out.println("余額不夠,至少保留余額:" + min);
} else {
balance = balance - f;
System.out.println("當前余額:" + balance);
}
}
public void query() {
System.out.println("您的當前余額:" + balance);
}
public static void main(String[] args) {
Account jame = new Account("111111", "張傑", "浙江大學", 200);
jame.deposit(350);
jame.withdraw(300);
jame.withdraw(300);
jame.query();
}
}