这是我到目前为止所得到的。我也不知道如何显示最小和最大,偶数和奇数输入。有人请帮忙
int value = -1;
Scanner scanner = new Scanner(System.in);
while(value < 0)
{
System.out.print("Enter a value > 0: ");
value = scanner.nextInt();
}
if(value < 0)
System.out.println("sorry write a value > 0");
}
答案 0 :(得分:0)
这有帮助吗?
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner value = new Scanner(System.in);
int number =value.nextInt();
if (number < 0 ) {
System.out.println("Value entered less than zero");
}
else if (number == 0) {
System.out.println("Value entered is equal to zero");
} else {
System.out.println("Value must have been greater than zero.");
}
}
}