Testing if an input is Integer and larger than (two conditions) with do-while loop - Java
问题 I need input from a user to be integer and larger than 10. Here is my code. import java.util.*; //program uses class Scanner public class Tests { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter an Integer"); int weight; do { while (!input.hasNextInt()) { System.out.println("Please enter an integer!"); input.next(); // this is important! } System.out.println("Enter an Integer >= 10"); weight = input.nextInt(); } while (weight < 10);