Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA PROGRAM In Exercise, The Account class was defined to model a bank account. An account has the properties account number, balance, annual interest

IN JAVA PROGRAM

In Exercise, 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 method to deposit and withdraw funds. Create two subclass 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, SavingAccount, and CheckingAccount and invokes their toString() methods.

Add a method named AccoundInf to implement the concept of polymorphism to display all the details of an account (This method can display the information of different types of Bank accounts). This method is not a class member method, it is outside the class.

This is how account class look like

public class Account { // instance variables private String accountNumber; private float balance; private float annualInterest; private Date createdDate; // Account constructor public Account(String accountNumber, float balance, float annualInterest) { this.accountNumber = accountNumber; this.balance = balance; this.annualInterest = annualInterest; this.createdDate = new Date(); } // function for deposit amount public void deposit(float amount){ if(amount>0) this.balance += amount; } // function for withdraw amount public void withdraw(float amount){ if(amount <= this.balance){ this.balance -= amount; } } // overriden to String @Override public String toString() { return "Account Details" + " Account Number: '" + accountNumber + '\'' + " Balance: " + balance + " Annual Interest: " + annualInterest + " Created Date: " + createdDate.toString(); } }

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions