⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testaccountclass.java

📁 这是银行模拟系统,能够得出存钱数和取钱数
💻 JAVA
字号:
public class TestAccountClass {
	public static void main (String[] args){
		
		Account money = new Account(1122,20000,0.045);
		
		money.withdraw(2500);
		
		money.deposit(3000);
		
		System.out.println("The balance is "+money.getBalance());
		System.out.println("The monthly interest is "+money.getMonthlyInterestRate());
	}
	
}

class Account {
	
	private int id;
	
	private double balance;
	
	private double annualInterestRate;
	
	Account (){
	}
	
	Account(int newId , double newBalance , double newAnnualInterestRate){
		
	id = newId;
	
	balance = newBalance;
	
	annualInterestRate = newAnnualInterestRate;	
	}
	
	/**return the id of the account */
	
	public int getId(){
		
		return id;
	}
	
	/** return the balance of the account */
	
	public double getBalance(){
		
		return balance;
	}
	
	/** return the interest rate of the account */
	
	public double getAnnualInterestRate(){
		
		return annualInterestRate;
	}
	
	/** set a new id */
	
	public void setId ( int newId){
		
		id = newId;
	}
	
	/** set a new balance */
	
	public void setBalance (double newBalance){
		
		balance = newBalance;
	}
	
	/** set a new interest rate */ 
	
	public void setInterestRate (double newInterestRate){
		annualInterestRate = newInterestRate;
	}
	
	public double getMonthlyInterestRate(){
		
		double monthlyInterestRate = annualInterestRate / 1200;
		return monthlyInterestRate;
	}
	
	public void withdraw(double amount){
		
	  balance -= amount;	
	}
	
	public void deposit ( double amount){
		balance += amount;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -