A real-world C++ problem

5 pts.
Tags:
C
OOPS
Software development
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. Question statement 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

Answer Wiki

Thanks. We'll let you know when a new response is added.

i think you can implement atry catch throw facilities to implement this.
ypu must check in try &catch exception that amount is never less than zero.
and if amount goes negative you must proide a message and say “enter valid amount”.
and go for exit

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • BrentSheets
    Moderator Note: Hi Wyasser. I see this is your first question, so welcome to IT Knowledge Exchange. As Schmidtw pointed out - you need to provide more information. Don't expect members to provide complete code solutions based on your requirements. But if you've run into a specific problem while trying to code this yourself - then please provide more information and someone may be able to help. Thanks.
    6,925 pointsBadges:
    report
  • FonePhiXeR
    Hello! I am new to programming, and would love to read the solution to this problem. I do understand that you do not want to do people's homework for them, so I will try my best to solve this one and submit. If possible, feel free to email me your solution. p.s. (I am not in any class right now, but will be taking IT classes this fall. )
    10 pointsBadges:
    report
  • carlosdl
    Hi FonePhiXeR. We don't do people's homework here, but I'm sure the community would be willing to help if specific questions are asked, and the question asker shows the work he/she has already done and the solutions he/she has already tried. Happy coding.
    69,240 pointsBadges:
    report
  • TheFinder
    I agree, you need to show your work thus far, and then maybe one would feel better about assisting you in your quest. We could better then maybe explain what it is that your doing wrong or explain things about your trial that you would understand, since it's based off of your own work. Asking questions I believe is part of doing homework, noting wrong with that, but to post the entire work assignment and expect then to get it built for you is kind of cheating, and we know cheaters don't really learn any thing, and we know you would feel better learning.
    1,940 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following