I run the program, but none of my lines are executed. When I say this to stop it is a red The error message prints. Exception in the thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor (unknown source) java.util on java.util.Scanner.nextInt (Unknown Source) java on
thread Scanner.net (unknown source) at .util.Scanner.nextInt (unknown source)
Here's my code, really does not seem to be anything out of normal for my limited experience And until I write it, my IDE does not report any errors.
import java.util.Scanner; Public category 312easf2 {public static zero main (string [] args) {scanner keyboard = new scanner (System.in); Int grade = 0; // In order to suppress the status of the loop, the initial value is double average grade = 0.0; Int max = keyboard.nextInt (); Int min = max; Int next = keyboard.nextInt (); System.out.println ("Enter a non-negative integer (negative to close):"); Whereas (next> = 0); {If (next> maximum) maximum = next; And if (Next & lt; min); Min = next; Next = keyboard.nextInt (); }}}}
edit: Compose the answer in my answer, which you must fix still before your program works properly, but the real problem for now is your first Some rows have:
scanner keyboard = new scanner (System.in); Int grade = 0; // In order to suppress the status of the loop, the initial value is double average grade = 0.0; Int max = keyboard.nextInt (); Int min = max; Int next = keyboard.nextInt ();
Your program is executing something but it is not saying anything, and closes only after touching the error, because there is a mistake in the implementation of your program. The syntax is not error, though; It's just that you have forgotten a few important ones.
<< p>
A syntax issue Multiple are similar syntax problems, in your code that are actually legal syntax, This is the reason that your IDE and compiler are not complaining, however, they are actually a very common mistake which causes unexpected behavior.
Pay special attention to your semicolons, and try to see your code again or, use your debugger as suggested by Gabe, who is giving you a good idea of what happens. Used to be.
Comments
Post a Comment