新手问题 验证用户输入
要求用户输入一个whole number 和非负数,然后验证用户输入的是否正确
下面的是例子。 谢谢。
Enter the distance in centimeters
553
553 cm = 0 miles, 6 yards, 0 feet, and 1.79 inches
Enter the distance in centimeters
-5
Exception in thread "main" java.lang.RuntimeException: Value out of range
....
Enter the distance in centimeters
2.5
Exception in thread "main" java.util.InputMismatchException
...
Enter the distance in centimeters
a
Exception in thread "main" java.util.InputMismatchException
下面的是例子。 谢谢。
Enter the distance in centimeters
553
553 cm = 0 miles, 6 yards, 0 feet, and 1.79 inches
Enter the distance in centimeters
-5
Exception in thread "main" java.lang.RuntimeException: Value out of range
....
Enter the distance in centimeters
2.5
Exception in thread "main" java.util.InputMismatchException
...
Enter the distance in centimeters
a
Exception in thread "main" java.util.InputMismatchException
...全文


Java SE
