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

PLEASE HELP! This is java. Write a class called Account that does not contain a

ID: 653867 • Letter: P

Question

PLEASE HELP! This is java.

Write a class called Account that does not contain a main() method, but it does contains the following:

A private int data field named id for the account (default value is 0).

A private double data field named balance for the account (default value is 0).

A private double data field named annualInterestRate that stores the current interest rate (default value is 0).

A private Date data field named dateCreated that stores the date when the account was created.

A no-arg constructor that creates a default account.

A two argument constructor that creates an account with the specified id and initial balance.

The accessor and mutator methods (getter and setter methods) for id, balance, and annualInterestRate.

The accessor method (getter method) for dateCreated.

A public double method named getMonthlyInterestRate() that returns the monthly interest rate.

A public double method named getMonthlyInterest() that returns the monthly interest.

A public void method named withdraw() that withdraws a specified amount from the account.

A public void method named deposit() that deposits a specified amount to the account.

A public String method named toString() that returns a string that contains the account ID, the account balance, the annual interest rate, and the date of the createion of the account.

The getMonthlyInterest() method is to return the monthly interest, not the monthly interest rate. Monthly interest is determined by the following formula:

    monthly interest = balance * monthlyInterestRate

The monthlyInterestRate value in the above equation is given by the following formula:

    monthly interest rate = annualInterestRate / 12

The toString() method will format the data into a string like the following:

    Account ID:             34598755

    Account Balance:        $2754.45

    Interest Rate:          2.75%

    Date Opened:            Sun Nov 2 14:18:16 EDT 2014

Note that annualInterestRate is a percentage, like a value of 4.5 for 4.5%. You need to divide it by 100 for the above equations.

Next, write a test program called TestAccount.java that has a main() method, and that creates an Account object named myAccount 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. Then print the balance, the monthly interest, and the date when this account was created. To print this information from your myAccountobject, use a line like the following:

    System.out.println(myAccount);

Then print the Monthly Interest Rate by calling getMonthlyInterestRate(), and then print the Monthly Interest by calling getMonthlyInterest().

Next, create an account object named yourAccount with a different ID, a different balance, and a different annual interest rate. Then print all of the same information you just printed for the myAccount object.

This is what I have so far:

It is not working...

class Account
{
   int id;
   double bal_amt;
   double annualInterestRate;
   Date date_created;
   Account()
   {
   id = 0;
bal_amt = 0.0;
annualInterestRate = 0.0;
   }
   Account (int newId, double newBal_amt)
   {
id = newId;
bal_amt = newBal_amt;
   }
   Account (int newId, double newBal_amt, double newAnnualInterestRate)
   {
id = newId;
bal_amt = newBal_amt;
annualInterestRate = newAnnualInterestRate;
   }
   public int getId()
   {
return id;
   }
   public double getBal_amt()
   {
return bal_amt;
   }
   public double getAnnualInterestRate()
   {
return annualInterestRate;
   }
   public void setId(int newId)
   {
id = newId;
   }
   public void setBal_amt(double newBal_amt)
   {
bal_amt = newBal_amt;
   }
   public void setAnnualInterestRate(double newAnnualInterestRate)
   {
annualInterestRate = newAnnualInterestRate;
   }
   public void setDate_created(Date newDate_created)
   {
date_created = newDate_created;
   }
   double get_interestRate()
   {
return annualInterestRate/12;
   }
   double withdraw_amt(double amount)
   {
return bal_amt -= amount;
   }
   double deposit(double amount)
   {
return bal_amt += amount;
   }
}

import java.util.Date;
public class TestAccount {
   public static void my_Accountin(String[] args)
   {
Account my_Account = new Account (3569, 40000.00, 0.094);
my_Account.withdraw_amt (2500.00);
my_Account.deposit(3000.00);
System.out.println("Balance: $" + my_Accpunt.bal_amt);
System.out.println("Monthly Interest: $ " + my.Account.get_interestRate());
java.util.Date date_created = new java.util.Date();
System.out.println("Account created on " + date_created.toString());
   }
}

Explanation / Answer

class Account{

private int id;

private double balance;

private double annualInterestRate;

private Date dateCreated;

Account()

{ this. id = 0;
  this.balance = 0.0;
  this.annualInterestRate = 0.0;

}

Account(int new_id, double in_bal)

{ this.id=new_id;

this.balance=in_bal;

}

Account(int new_id, double in_bal,double air)

{ this.id=new_id;

this.balance=in_bal;

this.annualInterestRate=air;

}

public int getId() {

        return id;

    }

       

    public void setId(int new_id) {

        id = new_id;

    }

public double getBalance() {

        return balance;

    }

       

    public void setBalance(double new_bal) {

        balance = new_bal;

    }

public double getAIR() {

        return annualInterestRate;

    }

       

    public void setAIR(double new_air) {

        annualInterestRate = new_air;

    }

public Date getDate() {

        return dateCreated;

    }

public double getMonthlyInterestRate()

{return annualInterestRate /12;}

public double getMonthlyInterest()

{return ( (annualInterestRate /12)/100)*balance;}

public void withdraw(double amount)

{balance= balance-amount;}

public void deposit(double amount)

{balance=balance+amount;

}

public String toString()

{return String.format (

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote