我正在为此苦苦挣扎。我知道如何编写代码来确定一个数字是否在 1.0 和 10.0 之间。假设 noOfJudges 是有效输入(3 到 9 之间)
for(noOfJudges = 0; noOfJudges < scores.length; noOfJudges++) {
scores[noOfJudges]=console.nextDouble();
while((scores[noOfJudges] < 1.0)||(scores[noOfJudges] > 10.0)) {
System.out.print("Please reenter the score (must be between 1.0 and 10.0, in .5 increments): ");
scores[noOfJudges] = console.nextDouble();
System.out.println();
}
System.out.println();
变量的有效输入应介于 1.0 和 10.0 之间,增量为 0.5,即 4.2 不是有效输入,但 4.5 是。不知道如何在这里进行...