我正在努力与此。我知道如何编写代码来确定数字是否在1.0和10.0之间。假设noOfJudges是有效的输入端(3之间和9)基本的Java - 验证间隔小数
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();
为变量A有效的输入将是1.0和10.0之间,增量为0.5,即4.2不是有效的输入,但是4.5。不知道如何继续在这里...
'4.55'和'4.45',它们有效吗? – vidit 2013-04-28 03:13:03
没有1.0,1.5,2.0,2.5,3.0,3.5 ... 9.0,9.5和10.0是有效输入 – Darw1n34 2013-04-28 03:20:13