Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

numbers using 9.1 17 Account class) Design a class named Account that contains A private int data field named i for the account (defaul om. A private double data lield named balance for the account default o) A private double data field named annual InterestRate that cur. rent interesi rate edefault 01. Assume all accounts have the sme inerest rate A private Date data field named datecreated that skres 1he date when account was crea Ano-arg const nuctor that creates a default accourr A constructor that creates an account with the specified id and initial halance. The accessor and mutator meth for id balance and annual InterestRate The accessor method for datecreated. a A method named getMonthlyInterestRatec) that returns the monthly A method named getMonthlyInteresto that returns the monthly imerest. A method named withdraw that withdraws a specified amount from the A method named deposit that deposits a specified amount to the account. Draw the UMI. diagram lor the class and then implement the class. (Hist: The method getMonthlyInterestO is to return monthly interest, nok the interest rare, Monthly interest is balance monthlyInterestRate. monthlyInterestRate is annual InterestRate 12. Note that annualInterestRate is a percentage eg.. like 4.5 You need to divide it by 100,) write a test program that creates an Account ohject with an account ID of 1122. a balance of $20,000 and an annual interest rate of 4.5%. Use the withdraw method to withdraw $2,500, use the deposit method to deposit $3,000, and print the balance, the monthly interest, and the date when this account was created

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());
    }
}