1. DivideByZeroException as a derived class of Standard Library class runtime_error, that is used to detect division by zero run time error. 2. NegativeNumberException as a derived class of Standard Library class logic_error, that is used to detect if the user entered a negative number as a grade. 3. InvalidGradeException as a derived class of Standard Library class logic_error, that is used to detect if a user entered an invalid input (grade greater than total grade). Use the above exception classes after implementing them to apply exception handling for your getPercentage function.
Implement function getPercentage that takes two inputs : grade and totalGrade and outputs the grade
percentage as follows: percentage = (grade/total grade)*100 . (Assume a student can not get a grade above 100%)
Define your own exception classes:
1. DivideByZeroException as a derived class of Standard Library class runtime_error, that is used to detect division by zero run time error.
2. NegativeNumberException as a derived class of Standard Library class logic_error, that is used to detect if the user entered a negative number as a grade.
3. InvalidGradeException as a derived class of Standard Library class logic_error, that is used to detect if a user entered an invalid input (grade greater than total grade).
Use the above exception classes after implementing them to apply exception handling for your getPercentage function.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images