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

Need Netbeans Java array help. Part I- coding two java classes to calculate GPA

ID: 668482 • Letter: N

Question

Need Netbeans Java array help. Part I- coding two java classes to calculate GPA while printing out one student's information: Student:fName,lName,major, gradYear & CollegeClass: professorFName, professorLName, semester, creditsEarned. Part II- incorporate two more java classes: HomebasedStudent, subclass of Student (currentLocation, currentAffiliation) and HomebasedCollegeClass, subclass of CollegeClass (homebasedTAfName, homebasedTAlName). Calculate HomebasedStudent GPA plus print the currentLocation and currentAffiliation and in the Student main method print out the Student and homebasedStudents GPAs.

Explanation / Answer

//Program: using Netbeans IDE

// Student

package student;

public class Student {

    String fName;

    String lName;

    String major;

    int gradYear;

    Student(String fn,String ln,String maj,int gy)

    {

    this.fName=fn;

    this.lName=ln;

    this.major=maj;

    this.gradYear=gy;

    }

    public void display()

    {

    System.out.println("First Name:"+this.fName);

    System.out.println("Last Name:"+this.lName);

    System.out.println("Major:"+this.major);

    System.out.println("Graduation Year:"+this.gradYear);

    }

    public static void main(String[] args) {

    String fn="David";

    String ln="Anderson";

    String maj="Computer Science";

    int gy=1998;

    Student S= new Student(fn,ln,maj,gy);

    System.out.println("Student Details ");

    S.display();

    String pfn="Sanjose";

    String pln="Jackson";

    String sem="Third";

    int cr=31;

    College C= new College(pfn,pln,sem,cr);

    double gpa1=C.GPA();

    System.out.println("GPA:"+gpa1);

    fn="Jhonny";

    ln="Antony";

    maj="Computer Science";

    gy=2000;

    String cl="NewJersy";

    String ca="Professor";

    HomebasedStudent H=new HomebasedStudent(fn,ln,maj,gy,cl,ca);

    System.out.println(" Homebased Student Details ");

    H.display();

    pfn="Sanjose";

    pln="Jackson";

    sem="Third";

    cr=29;

    String taf="Ricky";

    String tal="Janson";

    HomebasedCollege HC=new HomebasedCollege(pfn,pln,sem,cr,taf, tal);

    double gpa2=HC.GPA();

    System.out.println("GPA:"+gpa2);

    }

}

---------------------------------------------------------------------------------------------------------------------------

// College

package student;

public class College {

    String professorFName;

    String professorLName;

    String semester;

    int creditsEarned;

    College(String fn,String ln,String sem,int cr)

    {

    this.professorFName=fn;

    this.professorLName=ln;

    this.semester=sem;

    this.creditsEarned=cr;

    }

    public double GPA()

    {

        double gpa=this.creditsEarned /15; // 15 is number of credit hours

        return gpa;

    }

}

---------------------------------------------------------------------------------------------------------------------------

// HomebasedStudent

package student;

public class HomebasedStudent extends Student {

   String currentLocation;

   String currentAffiliation;

   HomebasedStudent(String fn,String ln,String maj,int gy,String cl,String ca)

   {

       super(fn, ln, maj, gy);

       this.currentAffiliation=ca;

       this.currentLocation=cl;

   }

   @Override

   public void display()

   {

    System.out.println("Current Affiliation:"+this.currentAffiliation);

    System.out.println("Current Location:"+this.currentLocation);

   }

}

---------------------------------------------------------------------------------------------------------------------------

// HomebasedCollege

package student;

public class HomebasedCollege extends College{

    String homebasedTAfName;

    String homebasedTAlName;

   HomebasedCollege(String fn,String ln,String sem,int cr,String taf,String tal)

   {

       super(fn, ln, sem, cr);

       this.homebasedTAlName=taf;

       this.homebasedTAfName=tal;

   }  

  

}

---------------------------------------------------------------------------------------------------------------------------

//Output:

Student Details

First Name:David

Last Name:Anderson

Major:Computer Science

Graduation Year:1998

GPA:2.0

Homebased Student Details

Current Affiliation:Professor

Current Location:NewJersy

GPA:1.0

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