Please use Netbeans and UML diagram numbers using 9.1 17 Account class) Design a
ID: 3573799 • Letter: P
Question
Please use Netbeans and UML diagram
Explanation / Answer
import java.util.*;
public class Account{
private int id;
private double balance;
private double annualInterestRate;
private Date dateCreated;
public Account(){
this.id = 0;
this.balance = 0;
this.annualInterestRate = 0;
}
public Account(int id, double balance){
this.id = id;
this.balance = balance;
}
public int getId(){
return this.id;
}
public void setId(int id){
this.id = id;
}
public double getAnnualInterestRate(){
return this.annualInterestRate;
}
public void setAnnualInterestRate(double annualInterestRate){
this.annualInterestRate = annualInterestRate;
}
public double getBalance(){
return this.balance;
}
public void setBalance(double balance){
this.balance = balance;
}
public Date getDateCreated(){
return this.dateCreated;
}
public double getMonthlyInterestRate(){
return this.annualInterestRate/12.0;
}
public double getMonthlyInterest(){
return this.annualInterestRate/12.0 * balance/100.0;
}
public void withdraw(double amount){
this.balance -= amount;
}
public void deposit(double amount){
this.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("Account Balance: " + account.getBalance());
System.out.println("Monthly Interest: " + account.getMonthlyInterest());
System.out.println("Date Created: " + account.getDateCreated());
}
}