0% found this document useful (0 votes)
47 views2 pages

IPA42

The document outlines the creation of a class hierarchy in Java, including a Person class with attributes like firstName, lastName, age, and gender, as well as two subclasses: Student and Faculty, each with their own specific attributes. It also describes a Solution class with methods to find the student with the highest GPA and the faculty with the highest salary, along with instructions for user input and output formatting. The main method is responsible for invoking these methods and displaying the results based on user-provided data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views2 pages

IPA42

The document outlines the creation of a class hierarchy in Java, including a Person class with attributes like firstName, lastName, age, and gender, as well as two subclasses: Student and Faculty, each with their own specific attributes. It also describes a Solution class with methods to find the student with the highest GPA and the faculty with the highest salary, along with instructions for user input and output formatting. The main method is responsible for invoking these methods and displaying the results based on user-provided data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Create a class Person with the following attributes:

firstName - String
lastName - String
age - int
gender - char ('M' for male and 'F' for female)

Write getters, setters and parameterized constructor in the above mentioned


attribute sequence as required.

Create a class Student that extends the Person class and adds the following
attributes:

rollNo - String
course - String
semester - int
GPA - double

Write getters, setters and parameterized constructor in the above mentioned


attribute sequence as required.

Create a class Faculty that extends the Person class and adds the following
attributes:

employeeId - String
department - String
designation - String
salary - double

Write getters, setters and parameterized constructor in the above mentioned


attribute sequence as required.

Create a class Solution with the main method.

Implement two static methods - findHighestGPAStudent and findHighestPaidFaculty in


Solution class.

findHighestGPAStudent method:
This method will take an array of Student objects as input.
The method will return the Student object with the highest GPA.
If the array is empty, the method should return null.

findHighestPaidFaculty method:
This method will take an array of Faculty objects as input.
The method will return the Faculty object with the highest salary.
If the array is empty, the method should return null.

These above mentioned static methods should be called from the main method.

For findHighestGPAStudent method - The main method should print the roll number,
course and GPA of the returned Student object.
If the returned value is null then it should print "Sorry - No student is
available".

For findHighestPaidFaculty method - The main method should print the employee ID,
department and salary of the returned
Faculty object.
If the returned value is null then it should print "Sorry - No faculty is
available".
Before calling these static methods in main, use Scanner object to read the values
of two Student objects and two Faculty
objects referring attributes in the above mentioned attribute sequence.

Example Input:

First1
Last1
20
M
Roll1
Course1
2
3.8
First2
Last2
21
F
Roll2
Course2
3
3.9
Faculty1
Last3
35
M
ID1
Department1
Associate Professor
90000.0
Faculty2
Last4
40
F
ID2
Department2
Professor
100000.0

Output:

Roll2
Course2
3.9
ID2
Department2
100000.0

You might also like