Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions