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

Please review the Student.java program. • Construct 5 students with different na

ID: 3884795 • Letter: P

Question

Please review the Student.java program.

• Construct 5 students with different names and gpa

• Store these 5 students in a linked list

• Search the linked list and output the student with the highest gpa (just this bullet point needed, thanks)

A Student class with student name and GPA ik public class Student t private double gpa; private String studentName; Constructs a student. ik public Student(double studentGpa, String n) gpastudentGpa; studentName = n; Gets the current GPA of the student @return the GPA public double getGPAC return gpa; public String getName(O return studentName;

Explanation / Answer

import java.util.*;

class Student

{

private double gpa;

private String studentName;

public Student(double studentGpa, String studentName) {

      gpa = studentGpa;

    studentName = n;

}

public double getGPA() {

    return gpa;

}

public String getName() {

    return studentName;

}

}

//the Class that runs main() method

public class CheggQuestion

{

    public static void main(String args[])

    {

    //Creating an inBuilt linked list object which will contain

    //the student class objects..

    LinkedList<Student> allStudents=new LinkedList<Student>();

    //Creating student objects..

    Student Student(9.1,"Chandralekha");

    Student two=new Student(8.1,"Chary");

    Student three=new Student(9.8,"Ammulu");

    Student four=new Student(8.4,"Shan");

    Student five=new Student(9.9,"Praveen");

    //Adding these student objects to the above

    //created linked list

    allStudents.add(one);

    allStudents.add(two);

    allStudents.add(three);

    allStudents.add(four);

    allStudents.add(five);

    //Crating new object for Student class

    Student topper=new Student(-1,"");

    //Using iterator to run the linked list in order

    //creating an iterator

    //using Student class(linked list containing object's class)

    //and initializing using Linked list object

    Iterator<Student> iteration=allStudents.iterator();

    while(iteration.hasNext())

    {

          //<iterator>.next() will move

       //assign current object to temp

       //and move the pointer to forward

          Student temp=iteration.next();

       //Checking the grade and assigning to topper

          if(temp.getGPA() > topper.getGPA())

             topper=temp;

       }

       //Printing the topper details

       System.out.println("Topper Name :: "+topper.getName()+" Top Grade :: "+topper.getGPA());

   }

}

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