Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote