Question: C++ 1. Define the class called Student . The Student class has the following: a) Private data members: name (string), age (int), units (int). The
C++
1.
Define the class called Student. The Student class has the following:
a) Private data members: name(string), age(int), units(int). The units represent the number of quarter units students is enrolled in.
b) Define a default constructor as well as a constructor with parameters for the class Student.
c) The class must have get and set functions for all private data members. The set function for the data member units must throw out_of_range exception if the number of units is not between 1 and 15.
d) Include a function called tuition (double feePerUnit) that computes and returns the cost of registering for the number of units (in the private data member).
e) Overload the insertion (<<) operator to display student name and age.
f) Test the class Student by writing a main program in which a Student object with name = Tim, age =20 and units = 5 is created and displayed. Call the function tution(), you may pass 100 as feePerUnit to this function and display the returned value. Demonstrate that the set function for the units data member throws an out_of_range exception.
2. Define the class GradStudent that is derived from the class Student. The GradStudent has a private data member gradFee(double).
a) Define a default constructor as well as a constructor with parameters for the class GradStudent.
b) The class must have get and set functions for private data member gradFee.
c) Redefine the function tuition (double feePerUnit) that computes and returns the cost of registering for the number of units (in the private data member). This function must call the tution() function in the base class and add the gardFee to it. [5pts].
d) Overload the operator insertion (<<) for the GradStudent to display student name, age and gradFee.
e) Test the class GradStudent, the overloaded operator (<<) and the tuition function (pass 100 as feePerUnit) similar to the student class.
Both sections would be helpful, but #2 needed the most.
Thank you!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
