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

Write an abstract superclass encapsulating a college applicant: A college applic

ID: 3710094 • Letter: W

Question

Write an abstract superclass encapsulating a college applicant: A college applicant has two attributes: the applicant’s name and the college the applicant is applying to. This class has two non-abstract subclasses: one encapsulating an applicant for undergraduate school, and the other encapsulating an applicant for graduate school. An applicant for undergraduate school has two attributes: a SAT score and a GPA. An applicant for graduate school has one additional attribute: the college of origin. It also has a method that returns “from inside” if the college of origin is the same as the college applied to; otherwise, it returns “from outside”. You also need to include a class to test two classes.

Java please.

Explanation / Answer

Required java classes:

Super class:

public abstract class collegeApplicant

{

// two attributes:

String applicantName,applyingTo;

//Default constructor

collegeApplicant() {}

//parameterized constructor

public collegeApplicant(String applicantName, String applyingTo)

{

this.applicantName=applicantName;

this.applyingTo=applyingTo;

}

}

Sub classes:

1)first non-abstact class:

public class underGraduateSchool extends collegeApplicant

{

//two attributes: a SAT score and a GPA.

double SATScore,GPA;

//Default constructor

underGraduateSchool () {}

//parameterized constructor

public underGraduateSchool(String applicatName,String applyingTo,double SATScore,double GPA)

{

//using super() to set the name and applying values in super class

super(applicatName,applyingTo);

//assigning values to attributes

this.SATScore=SATScore;

this.GPA=GPA;

}

}

2)second non-abstact class:

public class graduateSchool extends collegeApplicant

{

//two attributes: a SAT score and a GPA.

double SATScore,GPA;

String collegeOfOrigin;

//Default constructor

public graduateSchool() {}

// parameterized constructor

public graduateSchool(String applicatName,String applyingTo,double SATScore,double GPA,String collegeOfOrigin)

{

//using super() to set the name and applying values in super class

super(applicatName,applyingTo);

//assigning values to attributes

this.SATScore=SATScore;

this.GPA=GPA;

this.collegeOfOrigin=collegeOfOrigin;

}

//method to test whether the same college or not

public String collegeChecker()

{

// if the college of origin is the same as the college applied to

if(super.applyingTo.equalsIgnoreCase(collegeOfOrigin))

return "from inside";

else

return "from outside";

}

}

Test class:

public class Test

{

public static void main(String[] args)

{

//creating objects of two sub-classes

underGraduateSchool obj1= new underGraduateSchool("Joe","Carniel School",78.90,3.5);

graduateSchool obj2= new graduateSchool("Joe","Standford College",78.90,3.5,"Standford College");

//calling collegeChecker() method

System.out.println(obj2.collegeChecker());

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote