logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Create a user-defined exception class InsufficientBalanceException that is a subclass of the built in Exception class.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Create a user-defined exception class InsufficientBalanceException that is a subclass of the built in Exception class. This class has an instance variable amount, an overloaded constructor that initializes this amount, and a getter that returns the amount. (10 points)

2. Create a class (CheckingAccount) that encapsulates a bank account user details such as Name, Account number and balance. It consists of the following methods & constructor: (10 points)

a. An overloaded constructor that set the name and account number of the person.

b. The getters for the name, account and the balance.

c. A deposit void method that takes one parameter/argument and increments the balance of the user by the value of the parameter (deposit made to the account).

d. A withdraw void method that takes an argument (the amount to be withdrawn) from the account. If the amount being withdrawn is less than the current balance then the balance is decremented by the amount withdrawn otherwise compute the shortage amount and throw the InsufficientBalanceException and send a parameter (shortage amount) while throwing the exception. (Hint: make use of throw and throws statements in the withdraw method)

3. Create a Bank client class that creates a checking account and deposits some amount to that account to start with. You can deposit multiple times. Then the user withdraws some amount from the bank. You may withdraw multiple times. Remember that withdrawing money should be able to handle any exception that may be thrown due to insufficient balance in the account. (10 points)

Hint: Use try and catch block to handle any exceptions thrown due to insufficient balance.

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

823 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

774 Answers

Hire Me
expert
Husnain SaeedComputer science

929 Answers

Hire Me
expert
Atharva PatilComputer science

896 Answers

Hire Me

Get Free Quote!

408 Experts Online