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

if the Account class was defined to model a bank account. An account has the pro

ID: 3655268 • Letter: I

Question

if 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 withdraw funds. Create two subclasses for checking and saving accounts. A checking account has an overdraft limit but the savings account cannot be overdrawn. Draw the UML diagram for the classes and then implement them. Write a test program that creates objects of Account, SavingsAccount and CheckingAccount and invokes their toString() methods.

Explanation / Answer

import javax.swing.JOptionPane; import java.util.Date; public class Account { private int id = 0; private double balance = 0; private double annualInterestRate = 0; private double withdraw = 0; private double deposite = 0; private double total = 0; private double monthly = 0; private Date date = new Date(); public Account() { } public Account(int id, double balance, double annualInterestRate){ this.id = id; this.balance = balance; this.annualInterestRate = annualInterestRate; } public int getId() { return this.id; } public double getBalance() { return this.balance; } public double getAnnualInterestRate() { return this.annualInterestRate; } public java.util.Date getDate() { return this.date; } public double getWithdraw() { return this.withdraw; } public double getDeposite() { return this.deposite; } public String toString() { return "Banking Account Information " + " Your Customer ID # " + id + " Starting Balnce $" + balance + " Annual Interest Rate " + annualInterestRate + "%" + " Withdraw Amount $" + withdraw + " Deposite Amount $" + deposite + " Subtotal $" + total + " Monthly Interest $" + Math.round(monthly * 100.0)/100.0 + " " + " " + "As of " + date; } }