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

JAVA Programming....An account has the propteries account number, balance, annua

ID: 656893 • Letter: J

Question

JAVA Programming....An account has the propteries account number, balance, annual interest rate, date created, and methods to deposit and withdraw funds. Create two subclassess, for checkings and savings accounts. A checking account has an overdraft limit, but a savings account cannot be overdrawn.

Here is the code I have for the original account class...I only need the two subclasses now created from this code..nothing fancy

//Ghost_Account.java
//Header file section
import java.util.Date;

//Create a a class named Ghost_Account
public class Ghost_Account
{
//Declare variables
private int id;
private double balance;
private double annualInterestRate;
private Date dateCreated;

// Constructor
Ghost_Account()
{
  //A private int data field named id
  //for the account (default 0)

  id = 0;
//A private double data field named balance
  //for the account(default 0)

  balance = 0;
//A private double data field named annualInterestRate
  //that stores the current interest rate (default 0).

  annualInterestRate = 0;
// A private Date data field named dateCreated
  //that stores the date when the account was created

  dateCreated = new Date();
}

// Parameterized Constructor
//A constructor that creates an account
//with the specified id and initial balance.

Ghost_Account(int ID, double BALANCE)
{
  id = ID;
  balance = BALANCE;
  dateCreated = new Date();
}
//The accessor and mutator methods for id,
//balance, and annualInterestRate

// Getter method for Id
public int getId()
{
  return id;
}

// Getter method for Balance
public double getBalance()
{
  return balance;
}

// Getter method for Annual Interest Rate
public double getAnnualInterestRate()
{
  return annualInterestRate;
}

// Setter method for Id.
public void setId(int id)
{
  this.id = id;
}

// Setter method for Balance

public void setBalance(double balance)
{
  this.balance = balance;
}

// Setter method for Annual Interest Rate
public void setAnnualInterestRate(double annualInterestRate)
{
  this.annualInterestRate = annualInterestRate;
}

// The accessor method for dateCreated.
public Date dateCreated()
{
  return dateCreated;
}

// A method named getMonthlyInterestRate()
//that returns the monthly interest rate

public double getMonthlyInterestRate()
{
  return annualInterestRate / 12.0;
}

// A method named withdraw that withdraws
//a specified amount from the account.

public void withdraw(double amount)
{
  balance = balance - amount;
}

// A method named deposit that deposits
//a specified amount to the account.

public void deposit(double amount)
{
  balance = balance + amount;
}
}

//Headers file section

import java.sql.Date;

import java.text.DecimalFormat;

//main class

public class Ghost_AccountDemo

{

// main method.

public static void main(String[] args)

{

//Formating the data using the DecimalFormat object.

DecimalFormat df = new DecimalFormat("##.##");

//create an Account object with an account ID of 1122,

//a balance of $20,000,

Ghost_Account account = new Ghost_Account(1122,20000);

//Set an annual interest rate of 4.5%

account.setAnnualInterestRate(4.5);

//The withdraw method $2,500 is withdrawn,

//and the deposit method is used to deposit $3,000

account.withdraw(2500);

account.deposit(3000);

//Display output

System.out.println("Final Balance : " + df.format(account.getBalance()));

System.out.println("Monthly interest : " +df.format(account.getMonthlyInterestRate()));

System.out.println("Account created date : " +account.dateCreated().toString());

}

}

Explanation / Answer

The following steps might be helpful