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.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

Answer in c++ Please.

Description:
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.
Transcribed Image Text:Description: 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.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Structured English
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage