I was given a simple assignment to accomplish, creating a grading scale that would give a student a letter grade for a value that was submitted. Everything seems to run smoothly except after the student is done - they need to enter "E" to exit the program... This is where I am lost because I receive this exception "Exception in thread "main" java.util.InputMismatchException"
. I know the outcome is something small that I am missing, but I cant figure it out here is the code that I currently have:
public static void main(String[] args) {
int letterGrade;//The overall letter grade
boolean prompt = true;
while (prompt) {
//Prompt the student to input their data
System.out.print("Please enter your exam score, or press E to exit :");
@SuppressWarnings("resource")
Scanner keyboard = new Scanner(System.in);
letterGrade = keyboard.nextInt();
if ((letterGrade >= 90) & (letterGrade <= 100)) {
System.out.println("The letter grade is A");
} else if ((letterGrade >= 80) & (letterGrade <= 89)) {
System.out.println("The letter grade is B");
} else if ((letterGrade >= 70) & (letterGrade <= 79)) {
System.out.println("The letter grade is C");
} else if ((letterGrade >= 60) & (letterGrade <= 69)) {
System.out.println("The letter grade is D");
} else if ((letterGrade >= 0) & (letterGrade <= 59)) {
System.out.println("The letter grade is F");
} else {
System.out.println("Invalid input, try again.");
}
}
String firstChar = "e";
String secondChar = "E";
{
if ((firstChar == secondChar)) {
System.out.println("Thank you for using the grading system");
} else {
System.out.println("Thank you for using the grading system");
}
{
}
}
{
}
}
}
WHAT am I missing? I've been at this for two weeks?