Here is my code:
How do i write the code so that it keeps asking the same questions until the value the user entered is in the 1 to 6 parameters?
Code:
System.out.println("Please enter the number you think the die will roll. The number must be between 1 and 6"); for (boolean numRun=true; numRun;) { Scanner sc = new Scanner(System.in); if (sc.hasNext()) { numInput = sc.nextInt(); if (numInput >= 1 && numInput <= 6) { numRun= false; System.out.println("The number you have entered is between 1 and 6"); } else { System.err.println("You have entered an incorrect value."); numRun=true; } } }
Comment