1 回答

TA貢獻(xiàn)1798條經(jīng)驗(yàn) 獲得超3個(gè)贊
首先,變量NUM_TEST聲明為int double;只需書寫double就足夠了。
另外,在最后的 print 語句中,有一個(gè)不匹配的左括號(hào);引用變量名也可以,NUM_TEST不用寫double(NUM_TEST)
以下代碼稍作修改,應(yīng)該可以正常工作:
Scanner in = new Scanner(System.in);
int test1 , test2 , test3;
double NUM_TEST= 3;
System.out.print("Input first test: "); // user prompt
test1 = in.nextInt(); // read in the next integer
System.out.print("Input second test: "); // user prompt
test2 = in.nextInt();
System.out.print("Input third test: "); // user prompt
test3 = in.nextInt();
System.out.println("Average test score is: " + (test3 + test2 + test1) / (NUM_TEST));
:)
添加回答
舉報(bào)