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

Project: The Account Class Problem Description: ( The Account class ) Design a c

ID: 3569127 • Letter: P

Question

Project: The Account Class

Problem Description:

(The Account class) Design a class named Account that contains:

Implement the class. Write a test program that creates an Account object 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.

Coding: (Copy and Paste Source Code here.

public class Test {

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

}

}

class Account {

// Implement the class here

}

Explanation / Answer

/*
* Java Program to Implement Binary Search Tree
*/

import java.util.Date;
import java.util.Scanner;

public class Account
{
   private int id=0;
   private double balance=0;
   private double annualInterestRate=0;
   private Date dateCreated;
   public Account(){
      
      
   }
   public Account(int id,double balance){
       this.id=id;
       this.balance=balance;
       Date dNow = new Date( );
       this.dateCreated=dNow;
   }
   public void setBalance(double balance){
       this.balance=this.balance+balance;
   }
   public double getBalance(){
       return balance;
   }
   public void setId(int id){
       this.id=id;
   }
   public double getId(){
       return id;
   }
   public void setAnnualInterestRate(double annual){
       this.annualInterestRate=annual;
   }
   public double getMonthlyInterest(){
       return annualInterestRate;
   }
   public Date getDateCreated(){
       return dateCreated;
   }
   public void withdraw(double amount){
       this.balance=this.balance-amount;
   }
   public void deposit(double amount){
       this.balance=this.balance+amount;
   }
   public double getMonthlyInterestRate(){
       double interest=(balance*annualInterestRate)/100;
       interest=interest/12;
       return interest;
   }
   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());

       }

}