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

in ( Java programming language) please help me with it thank you Post lab A High

ID: 3751694 • Letter: I

Question

in ( Java programming language)
please help me with it
thank you

Post lab A HighSchool application has a super class: Person. Using inheritance, you will create two new classes, Teacher and Student. A Teacher will be like Person but will have additional properties such as salary (the amount the teacher earns) and subject (e.g the Person class with additional properties (student ID and GPA) You can start with following classes: er Science, 'Chemistry. 'English, 'Other"). The Student class is derived from class Person protected String name; II name of the person protected int age; l person's age protected String gender; I/ "M" for male, "F" for female public Person(String name, int age, String gender)t this.name name; this.age age; this.gender gender @Override public String toString)( return name+ ", age:"+ age+".gender: " +gender Requirements i. Add "setters" and "getters" for all instance variables in the Person class and Student class. i. Write Student class that extends the parent class Person. a) Add two protected instance variables to the class for id (int) and GPA double). Choose appropriate names for the instance variables.

Explanation / Answer

class Person

{

protected String name;

protected int age;

protected String gender;

public Person(String name,int age,String gender)

{

this.name=name;

this.age=age;

this.gender=gender;

}

public String toString()

{

return name+", age: "+age+",gender: "+gender;

}

}

class Student extends Person

{

protected int id;

protected double GPA;

Student(String name,int age,String gender, int id,double GPA)

{

super(name,age,gender);

setID(id);

setGPA(GPA);

}

public int getID()

{

return id;

}

public double getGPA()

{

return GPA;

}

public void setID(int newId)

{

id=newId;

}

public void setGPA(double newGPA)

{

GPA=newGPA;

}

public String toString()

{

return super.name+", age: "+super.age+",gender: "+super.gender+", ID: "+id+", GPA: "+GPA;

}

}

class Teacher extends Person

{

protected String subject;

protected double salary;

Teacher(String name,int age,String gender, String subject,double salary)

{

super(name,age,gender);

setSubject(subject);

setSalary(salary);

}

public String getSubject()

{

return subject;

}

public double getSalary()

{

return salary;

}

public void setSubject(String newSubject)

{

subject=newSubject;

}

public void setSalary(double newSalary)

{

salary=newSalary;

}

public String toString()

{

return super.name+", age: "+super.age+",gender: "+super.gender+", Subject: "+subject+", Salary: "+salary;

}

}

class main

{

public static void main(String []args)

{

Student st=new Student("John",23,"Male",10,5.6);

System.out.println(st);

Teacher te=new Teacher("John",23,"Male","Physics",3500);

System.out.println(te);

}

}

If you need any help with the code, then just let me know in the comment section.