Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

java programming Question 3 (40 Points) Create a new NetBeans projects with the

ID: 3756627 • Letter: J

Question

java programming

Question 3 (40 Points) Create a new NetBeans projects with the name “Question3” In this problem we are trying to represent people in a school using inheritance. We have Person super class and two sub classes derived from it: Student and Teacher. A Teacher will be like Person but will have additional properties such as salary (the amount the teacher earns) and subject (e.g. “Computer Science”, “Chemistry”, “English”, “Other”). The CollegeStudent class will extend the Student class by adding a year (current level in college) and major (e.g. “Electrical Engineering”, “Communications”, “Undeclared”). The inheritance hierarchy would appear as follows: 2 Listed below is the Person base class to be used as a starting point for the Teacher class (You should know why I used protected. If you don’t know, it is time to read the book!). The Student class is derived from the Person class and used as a starting point for the CollegeStudent class: You need to complete the following tasks. 1. Add methods to “set” and “get” the instance variables in the Person class. These would consist of: getName, getAge, getGender, setName, setAge, and setGender. 3 2. Add methods to “set” and “get” the instance variables in the Student class. These would consist of: getIdNum, getGPA, setIdNum, and setGPA. 3. Override the toString() method to print information about Person. 4. Write a Teacher class that extends the parent class Person. Add instance variables to the class for subject (e.g. “Computer Science”, “Chemistry”, “English”, “Other”) and salary (the teachers annual salary). The subject should be of type String and salary of type double. Choose appropriate names for the instance variables. 5. Write a constructor for the Teacher class. The constructor will use ve parameters to initialize myName, myAge, myGender, subject, and salary. Use the super reference to use the constructor in the Person superclass to initialize the inherited values. 6. Write “setter” and “getter” methods for all of the class variables. For the Teacher class they would be: getSubject, getSalary, setSubject, and setSalary. 7. Write the toString() method which prints information about a teacher. Use a super reference to do the things already done by the superclass. 8. Write a CollegeStudent subclass that extends the Student class. 9. Add instance variables to the class for major (e.g. “Electrical Engineering”, “Communications”, “Undeclared”) and year (e.g. FROSH = 1, SOPH = 2, ...). The major should be of type String and year of type int. Choose appropriate names for the instance variables. 10. Write a constructor for the CollegeStudent class. The constructor will use seven parameters to initialize myName, myAge, myGender, myIdNum, myGPA, year, and major. Use the super reference to use the constructor in the Student superclass to initialize the inherited values. 11. Write “setter” and “getter” methods for all of the class variables. For the CollegeStudent class they would be: getYear, getMajor, setYear, and setMajor. 12. Write the toString() method for the CollegeStudent class that prints information about the college student. Use a super reference to do the things already done by the superclass.

Explanation / Answer

Please do let me know ,if u have any concern...