I am working on a program to average grades. For some reason my scanner or console is not letting me enter an answer for the third question and I am not sure why.
A lot of the code is commented out as it unneeded for now.
edit: I am not sure how to number lines of code here but the lines 23-28 I think are the problem
import java.text.DecimalFormat;
import java.util.Scanner;
public class GradeData {
public static void main(String[] args) {
int count = 0;
double grade = 0;
//decided to use double for grade in case user's want to be specific with
//decimal points.
String user;
boolean enter;
String name;
String enterAgain;
Scanner userInput = new Scanner(System.in);
System.out.println("Please enter your name: ");
name = userInput.nextLine();
System.out.println("Please enter a grade: ");
grade = userInput.nextDouble();
//System.out.println(user); //May not need this line
System.out.println("Would you like to continue entering grades? (y/n)");
enterAgain = userInput.nextLine();
if (enterAgain.equalsIgnoreCase("y"))
/*|| enterAgain.equalsIgnoreCase("Yes"))*/ {
System.out.println("Please enter another grade: "); }
/* if (user.getScore() > highScore) {
highScore = user.getScore();
}
System.out.println("High Score: "
+ DecimalFormat.format(grade));
user.setScore(0);
}*/
else {
enter = false;
userInput.close();
}
}
}