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 second-highest score.
Breaking it down
Capturing the user input and storing it in a Map where the key is the student's name and the score is the value. Since we need to find the two top scores, we can sort the map by value in descending order and limit the Stream. We can do this by creating a Comparator that will compare the values of the HashMap in reverse order. Finally we can output the values of the stream by using the Stream.forEach and calling the key and value of the map.