Create a class Student with data members age and marks, both of type integer. Provide a parameterized constructor and a set member function to set the data members. The age should be a positive number between 15 and 40 while the marks should be between 0 and 100. Create a class InvalidRange as exception handler of the Student class. Add two private data members (a string and an integer) to theclass InvalidRange. Provide appropriate constructor and get methods for the data members. The string should store the name of the function throwing the exception while the integer should store the invalid value the user has supplied. The student class should throw an exception if any of its member functions attempts to assign an invalid value to the data members. In the main program, create objects of class student, assign valid/invalid values to the data members and catch the exceptions accordingly. Extend the program to have two separate classes for exception handling, InvalidMarks and InvalidAge.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter12: Exception Handling
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question

i will upvotes unique answer plzz

(Use language OOP in c++)

Create a class Student with data members age and marks, both of type integer. Provide a parameterized constructor and a set member function to set the data members. The age should be a positive number between 15 and 40 while the marks should be between 0 and 100. Create a class InvalidRange as exception handler of the Student class. Add two private data members (a string and an integer) to theclass InvalidRange. Provide appropriate constructor and get methods for the data members.

The string should store the name of the function throwing the exception while the integer should store the invalid value the user has supplied. The student class should throw an exception if any of its member functions attempts to assign an invalid value to the data members.

In the main program, create objects of class student, assign valid/invalid values to the data members and catch the exceptions accordingly.

Extend the program to have two separate classes for exception handling, InvalidMarks and InvalidAge.

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT