A Real world Problem:
This is a business rule of a bank that the Balance of customer must always be Positive,
Further that it is also a business rule that a customer can not withdraw amount greater than his/her current balance.
You are required to write a C++ program to solve this real world problem, using Exception Handling.
Your program should consist of a class Customer and 4 instance variables. Cust_name, Cust_AC_No, Cust_balance, Amount_withdraw.
Cust_name : Customer Name
Cust_AC_No : Customer Account Number
Cust_balance : Customer Balance
Amount_withdraw : Amount that is to be withdraw
The class should further consists of getter and setter function for each instance variable.
The setter function of Cust_balance consists of a try and a catch block, if the user enters the balance less than zero (means negative, which is not possible) then this function should throw an exception, and its corresponding catch block should handle this exception by providing another opportunity to the user to enter the balance again.
Similarly the setter of Amount_withdraw variable should also have a try and a catch blocks. If the user enters the withdraw amount greater than the current balance then this function should throw an exception, and its corresponding catch block should handle this exception.
In main function just declare an object of Customer class and call all its setter and getter functions
March 6, 2009 6:01 AM
June 25, 2011 1:08 AM