0
我想從for循環中的數組值中獲取百分比。如何從數組中獲取百分比值
System.out.println(playerName[i+1] + " got " + playerScore[i] + " questions right out of " + question.length + "!\n");
double playerScorePercentage = (playerScore[i]/question.length) * 100;
System.out.println("Which is " + playerScorePercentage + "%!");
我在做什麼錯? playerScore
顯示一個值,但是當我試圖用下面的方法進行計算時,無論如何,它都會顯示0.0。
一個例子來看:
John got 3 questions right out of 10!
Which is 0.0%!