Question: (C++ Program) There is a class called Person which has name and age as private variables. Another class called Student, which is derived from person

(C++ Program)

There is a class called Person which has name and age as private variables.

Another class called Student, which is derived from person with gpa and id as variables.

name is a string, age and id are integers and gpa is a double... All of them are private variables.

age, gpa and id should be generated randomly when the object is created with the following ranges:

age 20 to 32

gpa 0.0 to 4.0 // this one is tricky to get as random doesnt generate decimal numbers.

id 1000 to 9999

In the start of the program, you will ask for how many students there are. dynamically create an array of students of that size. (we are not creating an object of type person for this program).

In a loop, you will ask for the names of each of these people (all the other data was already created randomly through the constructors).

Once you are done, you are to display everyone in the array neatly.

Sort the students by gpa (from highest to lowest, make sure you sort the students not just swapping of gpa) (do not use the bubbleish sort)

and display the sorted array neatly. (show the Students, not just the GPA's).

( please show output and comments)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!