Description: Implement function getPercentage that takes two inputs: grade and total Grade 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.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter11: Exception Handling
Section: Chapter Questions
Problem 2CP
icon
Related questions
Question
Description:
Implement function getPercentage that takes two inputs: grade and total Grade 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.
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.
Sample Input/Output:
Transcribed Image Text:Description: Implement function getPercentage that takes two inputs: grade and total Grade 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. 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. Sample Input/Output:
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Custom Exception class
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning