I run the program, but none of my lines execute. When I tell it to stop it prints a red error message.
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
Here's my code, nothing really seems to be out of the ordinary to my limited experience and my IDE doesn't report any errors while I'm writing it.
import java.util.Scanner;
public class 312easf2
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int grade = 0; // initial value to satify loop condition
double averageGrade = 0.0;
int max = keyboard.nextInt();
int min = max;
int next = keyboard.nextInt();
System.out.println("Enter a nonnegative integer (negative to stop): ");
while(next >= 0);
{
if(next > max)
max = next;
else if(next < min);
min = next;
next = keyboard.nextInt();
}
}
}