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

(Finding the two highest scores) Write a program that prompts the user to enter

ID: 3634309 • Letter: #

Question

(Finding the two highest scores) Write a program that prompts the user to
enter the number of students and each student’s name and score, and finally
displays the student with the highest score and the student with the secondhighest
score.

Explanation / Answer

this will help you..for getting the highest mark import java.util.*; class Student { String name; double marks; public Student(String n, double s){ name = n; marks = s; } public String getName(){ return name; } public double getMarks(){ return marks; } } public class ArrayListExample{ public static void main(String[] args){ Scanner input=new Scanner(System.in); double sum=0; String name=""; double marks=0; double secondMax=Double.MIN_VALUE; double maxNumber = Double.MIN_VALUE; ArrayList list = new ArrayList(); for(int i=1;i maxNumber) { maxNumber = marks; } if ((maxNumber>secondMax)&&(marks>secondMax)){ secondMax=marks; } list.add(new Student(name, marks)); } double average=sum/5; System.out.println("Name Marks"); for (Student s : list) System.out.println(s.getName()+" "+s.getMarks()); System.out.println("Average Marks= "+average); System.out.println("Highest Marks= "+maxNumber); System.out.println("second Highest="+secondMax); System.out.println("Name of Student achieved highest marks= "); for (Student s : list){ if(maxNumber == s.getMarks()){ System.out.println(s.getName()); } } } }