Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

24. Create a BankAccount class that models a typical bank account where you deposit and withdraw money. To keep things simple, assume this bank account

image text in transcribed

24. Create a BankAccount class that models a typical bank account where you deposit and withdraw money. To keep things simple, assume this bank account deals only with integral amounts. a. You should provide a constructor, a toString method, a getTotal method that returns an int, and both deposit and withdraw methods that take int arguments and return void. Also create an application UseBankAccount that demonstrates that the BankAccount class works correctly. Create a BankAccountException class. Change your deposit method so that it throws an appropriate exception if an attempt is made to deposit a b. Exercises negative amount. Do the same with the withdraw method, but also have it throw an exception if an attempt is made to withdraw more money than is avail- able. In each case include appropriate exception messages. Create three short applications that demonstrate each of the three exceptional situations-it is OK if the applications bombs, as long as it demonstrates that the appropriate excep- tion has been thrown Create a new application, Banker, that creates a BankAccount object and then interacts with users, allowing them to deposit or withdraw funds, or to request an account total. This application should not bomb in any of the exceptional situations-it should catch the exception, pass the message to the user and continue processing. c

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

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

what is a peer Group? Importance?

Answered: 1 week ago