Integer Division in Array Calculation
What is printed to the console when the following code is executed?
public class Main {
public static void main(String[] args) {
int[] scores = {88, 92, 76, 81};
int total = 0;
for (int i = 0; i < scores.length; i++) {
total += scores[i];
}
double average = total / scores.length;
System.out.println(average);
}
}
A
84.0
B
337
C
84.25
D
84
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | suhanakochhar006 | 0 | 1 | 0m 00s | 0 |
| #2 | singhris000 | 1 | 2 | 1m 32s | -2 |
| #3 | geethasailaja | 0 | 1 | 0m 15s | -25 |
| #4 | y.seong2027 | 1 | 2 | 2m 42s | -72 |
| #5 | suhanakochhar006 | 0 | 2 | 8m 47s | -547 |
| #6 | bommasam000 | 2 | 6 | 1h 33m | -5,466 |
APFIVE