Tuesday, 15 September 2015

java - WHILE Loop Condition Does Not Validate Input -


I have a WHILE loop that examines the digits for a particular student, however, This is not a loop if the value is invalid (input less than 0 and more than 100):

  int marks = -1; System.out.print ("Student Icon (/ 100):"); While (((mark> lt; 0) || (points> 100)) {try {marks = Integer.parseInt (sc.nextLine ()); break; } Hold (numerate expansion nfe) {System.err.println ("Error: invalid sign (s)"); System.out.print ("Student Icon (/ 100):"); }}  

This catches the exception if letters other than numbers are entered.

But it does not loop again if the value is less than 0 or greater than 100.

I have tried to make many changes for this, but no results.

Any help given is appreciated!

You should remove the break statement, because it will give you the Marks the input of the input marks without taking into account the light.


No comments:

Post a Comment