n c++ 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.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter9: Completing The Basics
Section9.1: Exception Handling
Problem 1E
icon
Related questions
Question

In c++

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. 

Sample Input/Output:
Please enter grade and total grade: (end-of-file to end)
99 100
your Percentage is: 99%
Please enter grade and total grade: (end-of-file to end)
95 e
caught Exception : attempted to divide by zero
Please enter grade and total grade: (end-of-file to end)
100 90
caught Exception : entered an invalid grade
Please enter grade and total grade: (end-of-file to end)
-10 100
caught Exception : entered a negative number as a grade
Please enter grade and total grade: (end-of-file to end)
10 -100
caught Exception : entered a negative number as a grade
Please enter grade and total grade: (end-of-file to end)
Transcribed Image Text:Sample Input/Output: Please enter grade and total grade: (end-of-file to end) 99 100 your Percentage is: 99% Please enter grade and total grade: (end-of-file to end) 95 e caught Exception : attempted to divide by zero Please enter grade and total grade: (end-of-file to end) 100 90 caught Exception : entered an invalid grade Please enter grade and total grade: (end-of-file to end) -10 100 caught Exception : entered a negative number as a grade Please enter grade and total grade: (end-of-file to end) 10 -100 caught Exception : entered a negative number as a grade Please enter grade and total grade: (end-of-file to end)
Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Header Files
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
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