/** * * @author musard The date is a hardcoded string. More realistically, we can use * java.util.Date to record the creation date. */ public class Account { private int id; private double balance; private static double annualInterestRate; private String dateCreated; public Account() { dateCreated = "September 21, 2016"; } public Account(int newId, double newBalance) { id = newId; balance = newBalance; dateCreated = "September 21, 2016"; } public int getId() { return this.id; } public double getBalance() { return balance; } public static double getAnnualInterestRate() { return annualInterestRate; } public void setId(int newId) { id = newId; } public void setBalance(double newBalance) { balance = newBalance; } public static void setAnnualInterestRate(double newAnnualInterestRate) { annualInterestRate = newAnnualInterestRate; } public double getMonthlyInterest() { return balance * (annualInterestRate / 1200); } public String getDateCreated() { return dateCreated; } public void withdraw(double amount) { balance -= amount; } public void deposit(double amount) { balance += amount; } public static void main(String[] args) { Account account = new Account(1122, 20000); Account.setAnnualInterestRate(4.5); account.withdraw(2500); account.deposit(3000); System.out.println("Balance is " + account.getBalance()); System.out.println("Monthly interest is " + account.getMonthlyInterest()); System.out.println("This account was created at " + account.getDateCreated()); } }