Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an BankAccount class and a Savings Account class which extends BankAccount The BankAccount class hold the following data for a bank account -Account holder

image text in transcribed
image text in transcribed
Write an BankAccount class and a Savings Account class which extends BankAccount The BankAccount class hold the following data for a bank account -Account holder name -Account Number Balance Number of deposits this month Number of withdrawals The dass should have the following methods: Deposit: A method that accepts an argument for the amount of the deposit. The method should add the argument to the account balance. It should also increment the variable holding the number of deposits. Withdraw A method that accepts an argument for the amount of the withdrawal. The method should subtract the argument from the balance. It should also increment the variable holding the number of withdrawals. getBalance Return the balance of the account storeAccount: This method will store the account holder name, account number and current Balance into file (account info.txt) Next, design a SavingsAccount dass that extends the BankAccount class. The SavingsAccount class should have a status field to represent an active or inactive account. If the balance of a savings account falls below $25, it becomes inactive. (The status field could be a boolean variable.) No more withdrawals can be made until the balance is raised above $25, at which time the account becomes active again. The savings account class should have the following methods Withdraw: A method that determines whether the account is inactive before a withdrawal is made. (No withdrawal will be allowed if the account is not active.) A withdrawal is then made by calling the superdass version of the method. Deposit: A method that determines whether the account is inactive before adeposit is made. If the account is inactive and the deposit brings the balance above $25, the account becomes active again. The deposit is then made by calling the superclass version of the method. Exception Handling At least, you must use three of the exception handling methods Test your code using main by a) Create one object from the subclass with starting balance 1500 and one deposit (350) and one withdraw (850) from the account. Then printout the account balance. b) Make the saving account inactive. Then printout the account balance and the number of withdrawals c)Make the saving account active again. Then printout the account balance and the number of deposits this month d) Use method storeAccount to store account information

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

Step: 3

blur-text-image

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions