public static double run() {
double r = 0;
for (int i = 1; i <= 4; i++) {
r += 1.0 / i;
}
return Math.round(r * 100) / 100.0;
}
// Call: System.out.println(run());What is printed?
- A
2.5
- B
2.0
- C
1.92
- Dcheck_circle
2.08
Explanation
1 + 0.5 + 0.333... + 0.25 = 2.0833. Round to 2 decimals = 2.08.