我正在努力與此。我知道如何編寫代碼來確定數字是否在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