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

Can someone pleasse help with the code and sample output below? /*--------------

ID: 664613 • Letter: C

Question

Can someone pleasse help with the code and sample output below?

/*---------------------------------------------------------------------------

Sample Output: The user input is in Bold

Please enter the total number of students:

3

Enter Student 1 Details: Name: John Doe

GPA (between 1 and 4): 3.2 Age: 23

Enter Student 2 Details:
Name: Linda Smith
GPA (between 1 and 4): 3.8 Age: 19

Enter Student 3 Details:
Name: Hillary Clinton
GPA (between 1 and 4): 3.6 Age: 56

Printing Student Details ... Name: John Doe

Age: 23 GPA: 3.2

Name: Linda Smith Age: 19 GPA: 3.8

Name: Hillary Clinton Age: 56 GPA: 3.6

The name of the student with highest GPA is: Linda Smith

Explanation / Answer

import java.util.ArrayList;
import java.util.Scanner;

class Lab8 {
double maxGPA = 0.0;
int maxGPAIndex= 0;
String stdName;
double stdGPA;
int stdAge;
public Lab8( String name, double maxGPA, int maxGPAIndex, double stdGPA, int stdAge){//constructor
this.stdName=name;
this.maxGPA=maxGPA;
this.maxGPAIndex=maxGPAIndex;
this.stdGPA=stdGPA;
this.stdAge=stdAge;
}
public String toString(){//to print details
return stdName+"having Age "+stdAge+" with maxGPA "+maxGPA+" maxGPAIndex "+maxGPAIndex+" standard GPA"+stdGPA;
}
public static void getHighestGPA(ArrayList<Lab8> list, int count){//calculating student with max GPA
double max=0.0;
int index=0;
for(int i=0; i < count; i++){
if(list.get(i).maxGPA>max){
max = list.get(i).maxGPA;
index=i;
}
}   
System.out.println("Details of Student with MAX GPA is: ");
System.out.println(list.get(index));
}
public static void main(String[] args){

int numOfStudents= 0;
Scanner scan = new Scanner(System.in);
System.out.println("Please enter the total number of students:");//reading number of students
int numberOfStudents= scan.nextInt(); // Dont remove this line
ArrayList<Lab8> list = new ArrayList<Lab8>();
double maxGPA = 0.0;
int maxGPAIndex= 0;
String stdName;
double stdGPA;
int stdAge;
for(int i=0; i < numOfStudents; i++) //creating new objects by reading details from user
{
System.out.println("Enter student name");
stdName=scan.nextLine();
System.out.println("Enter student age");
stdAge=scan.nextInt();
System.out.println("Enter student maxGPA");
maxGPA=scan.nextDouble();
System.out.println("Enter stdGPA");
stdGPA=scan.nextDouble();
System.out.println("Enter max GPAIndex");
maxGPAIndex=scan.nextInt();
list.add(new Lab8(stdName,maxGPA,maxGPAIndex,stdGPA,stdAge));
}
// print out the details of all the students using for loop
System.out.println(" Printing Student Details ...");
for(int i=0; i < numOfStudents; i++){
System.out.println(list.get(i));
}
getHighestGPA(list,numOfStudents);//finally calling method


}//end main

}//end Lab8