Write a C++ program that creates a class Mathematician with the
data members such as name, address, id, years_of_experience and
degree and create an array of objects for this class.
Include public member functions to
i) Input() – This function should read the details
of an array of Mathematicians by passing array of objects and array
size (n)
ii) Display() – This function should display either the
details of an array of Mathematicians or a Mathematician with
highest experience by passing array of objects, array size (n) and
user’s choice (1 or 2) as the argument to this function.
Note:-
Write the main function to
Create an array of objects of Mathematician based on the user’s
choice (get value for the local variable ‘n’ and decide the size of
the array of objects)
Input details into the array of objects.
Finally, either display the complete set of Mathematician
details or display the details of Mathematician with highest years
of experience based on the user’s choice.
(1 – display the complete set of Mathematician
details)
or
(2 – display Mathematician with highest experience details
only)
You may decide the type of the member data as per the
requirements.
Output is case sensitive. Therefore, it should be produced as
per the sample test case representations.
‘n’ and choice should be positive only. Choice should be either
1 or 2. Otherwise, print “Invalid”.
In samples test cases in order to understand the inputs and
outputs better the comments are given inside a particular notation
(…….). When you are inputting get only appropriate values to the
corresponding attributes and ignore the comments (…….) section. In
the similar way, while printing output please print the appropriate
values of the corresponding attributes and ignore the comments
(…….) section.
Sample Test cases:-
case=one
input= 3 (no of Mathematician details is to be entered)
Raju (name)
Pollachi (address)
135 (id)
10 (experience)
PhD (degree)
Pandiyan (name)
Tirupathi (address)
136 (id)
8 (experience)
PhD (degree)
Mani (name)
Bihar (address)
137 (id)
11 (experience)
PhD (degree)
2 (Choice to print Mathematician with highest experience)
output=Mani (name)
Bihar (address)
137 (id)
11 (experience)
PhD (degree)
grade reduction=15%
case=two
input= -3 (no of Mathematician details is to be entered)
output=Invalid
grade reduction=15%
case=three
input= 3 (no of Mathematician details is to be entered)
Rajesh(name)
Pollachi (address)
125 (id)
10 (experience)
PhD (degree)
Pandiyaraj (name)
Tirupathi (address)
126 (id)
8 (experience)
PhD (degree)
Manivel (name)
Bihar (address)
127 (id)
11 (experience)
PhD (degree)
3 (Wrong choice)
output=Invalid
grade reduction=15%
case=four
input= 2 (no of Mathematician details is to be entered)
Rajedran (name)
Pollachi (address)
100 (id)
10 (experience)
PhD (degree)
Pandey (name)
Tirupathi (address)
200 (id)
8 (experience)
MSc (degree)
1 (Choice to print all Mathematician details in the given
order)
output=Rajedran (name)
Pollachi (address)
100 (id)
10 (experience)
PhD (degree)
Pandey (name)
Tirupathi (address)
200 (id)
8 (experience)
MSc (degree)
grade reduction=15%
Write a C++ program that creates a class Mathematician with the data members such as name, address, id, years_of_experie
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am