Sunday 15 March 2015

java.util.inputMismatchException Dont know why -


I am trying to write a small program to calculate some grades, but I have a inputMismatchException , but I do not know why the problem is that I get an exception before I even got an opportunity to enter an integer.

Can anyone help me out?

  public static zero main (string [] args) {scanner input = new scanner ("System.in"); Int pass = 0; Intel Failure = 0; Int studentCounter = 1; Full result; While (StudentConcentor & lt; = 10) {// Zelangpang = Output Gwijjighed System.out.print ("Gift Hate as a result (1 = Gisalagad, 2 = Grabid)"); Results = input.nextInt (); If (results == 1) {passes = passes + 1; } And {failures = failures + 1; } StudentCounter = studentCounter + 1; } // Zelf Egepast = Output Gizzygied System. Out.printf ("Antal Lirlingen Gisalagad:% D \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"; If (close> 8) {// ZelfangEngest = Output Geiszgied System.out.print ("waste for bonuses!"); }}}   

So you can see that I can not specify any number in variable result.

This means that the scanner ( input ) Nothing found which is expected from nextInt

It is thrown by the scanner to indicate that the token was retrieved from the pattern for the expected type Does not match or the token is out of range for the expected type.

In short, the scanner that you give, the next token is not an integer.

No comments:

Post a Comment