4 38 C2 Tue Nov 29 1 14 12 PM E Chrome File Edit View Histor
Solution
// Account.java
import java.util.Date;
public class Account{
    private int id;
    private double balance;
    private double annualInterestRate;
    private Date dateCreated;
    public Account() {
        id = 0;
        balance = 0;
        annualInterestRate = 0;
        dateCreated = new Date();
    }
    public Account(int id, double balance) {
        this.id = id;
        this.balance = balance;
        this.dateCreated = new Date();
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public double getBalance() {
        return balance;
    }
    public void setBalance(double balance) {
        this.balance = balance;
    }
    public double getAnnualInterestRate() {
        return annualInterestRate;
    }
    public void setAnnualInterestRate(double annualInterestRate) {
        this.annualInterestRate = annualInterestRate;
    }
    public Date getDateCreated() {
        return dateCreated;
    }
    public double getMonthlyInterestRate(){
        return annualInterestRate / 12.0;
    }
    public double getMonthlyInterest(){
        return this.getMonthlyInterestRate() * balance / 100.0;
    }
    public void withdraw(double amount){
        if(balance > amount) balance -= amount;
        else System.out.println(\"Insufficient balance!\");
    }
    public void deposit(double amount){
        balance += amount;
    }
 }
// Test.java
public class Test{
    public static void main(String args[]){
        Account object = new Account(1122, 20000);
        object.setAnnualInterestRate(4.5);
        object.withdraw(2500);
        object.deposit(3000);
        System.out.println(\"Balance: \" + object.getBalance() + \"\ Monthly interest: \" + object.getMonthlyInterest() + \"\ Date of creation: \" + object.getDateCreated());
    }
 }


