Question: JAVA class Account { protected int id; protected double balance; protected static double annualInterestRate; protected java.util.Date dateCreated; public Account() { dateCreated = new java.util.Date(); }

JAVA

JAVA class Account { protected int id; protected double balance; protected static

class Account {

protected int id;

protected double balance;

protected static double annualInterestRate;

protected java.util.Date dateCreated;

public Account() {

dateCreated = new java.util.Date();

}

public Account(int newId, double newBalance) {

id = newId;

balance = newBalance;

dateCreated = new java.util.Date();

}

public int getId() {

return this.id;

}

public double getBalance() {

return balance;

}

public static double getAnnualInterestRate() {

return annualInterestRate;

}

public void setId(int newId) {

id = newId;

}

public void setBalance(double newBalance) {

balance = newBalance;

}

public static void setAnnualInterestRate(double newAnnualInterestRate) {

annualInterestRate = newAnnualInterestRate;

}

public double getMonthlyInterest() {

return balance * (annualInterestRate / 1200);

}

public java.util.Date getDateCreated() {

return dateCreated;

}

public void withdraw(double amount) {

balance -= amount;

}

public void deposit(double amount) {

balance += amount;

}

}

11.3 (Subelasses of Account) In Programming Exercise 9.7, the Account class was defined to model a bank account. An account has the properties account number. balance, annual interest rate, and date created, and methods to deposit and with- draw funds. Create two subclasses for checking and saving accounts. A checking account has an overdraft limit, but a savings account cannot be overdrawn. Draw the UML diagram for the classes and implement them. Write a test program that creates objects of Account, SavingsAccount, and CheckingAccount and invokes their toString) methods

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!