C++ Programming : instead of returning -1 it should throw exception using except
ID: 3566351 • Letter: C
Question
C++ Programming :
instead of returning -1 it should throw exception using exception class. write three exceptions
(1) Exception_Neg_Deposit //entering negative deposit
(2) Exception_Overdraw // taking out more than the balance amount
(3) Exception_Neg_Withdraw //taking out negative amount from the account
double deposit(double amt)
{
if (amt > 0)
total += amt;
else
return -1; //
return total;
}
double withdraw (double amt)
{
if((amt > total) || (amt < 0))
return -1;
else
total -= amt;
return total;
}
instead of returning -1 it should throw exception using exception class. write three exceptions
(1) Exception_Neg_Deposit //entering negative deposit
(2) Exception_Overdraw // taking out more than the balance amount
(3) Exception_Neg_Withdraw //taking out negative amount from the account
Explanation / Answer
o/p:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.