Trying to figure out how to adjust my code to match the output in the picture. When asked for the student's name the second time in the output when I enter a string I receive an error message. I am trying to get the while-loop to continue asking me for the student's name and their score until I type in "alldone" for the student's name for the program to display the student's name who has the highest score.
Instructions & Expected output picture: click here
import java.util.Scanner;
public class practice {
public static void main(String[] args) {
//Scanner Object
Scanner input = new Scanner(System.in);
//Variables
String name = "Nobody";
String highName = "";
int highScore = 0;
//While-Loop
while (!name.equals("alldone")) {
//User Input Required
System.out.println("Please enter student's name, or \"alldone\" if finished >");
name = input.nextLine();
System.out.println("Please enter student's score >");
int score = input.nextInt();
//If statement
if ((name != "alldone") && (score > highScore)) {
highName = name;
highScore = score;
}else {
}
}
//Output: highName + highScore
System.out.println(highName + " had the highest score which was " + highScore);
//Closed Scanner Object
input.close();
}
}