Java Arithmetic Expression Evaluation
Consider the following incomplete calculateExpression method.
public static double calculateExpression(int a, int b, int c) {
/* missing statement */
return result;
}
The method is intended to work as demonstrated by these examples:
- A call to
calculateExpression(5, 4, 2)returns10.0. - A call to
calculateExpression(6, 3, 2)returns9.0.
Which of the following statements, if substituted for /* missing statement */, will cause the method to work as intended?
A
double result = a / b * c + a;
B
double result = a + b * c - (a / c);
C
double result = (a * b) / c;
D
double result = a * (b - c) + a / c;
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | 108185265 | 3 | 3 | 0m 18s | 282 |
| #2 | liuwilliam072410 | 1 | 1 | 0m 28s | 72 |
| #3 | lsj08030922 | 1 | 1 | 0m 42s | 58 |
| #4 | raufyildirim95 | 1 | 1 | 0m 46s | 54 |
| #5 | hmbin999 | 1 | 1 | 0m 58s | 42 |
| #6 | parth.taur227 | 1 | 1 | 1m 04s | 36 |
| #7 | sarah.alyahya90tt | 0 | 1 | 0m 00s | -10 |
| #8 | geethasailaja | 2 | 3 | 4m 13s | -63 |
| #9 | bommasam000 | 1 | 3 | 3m 12s | -112 |
| #10 | patrickmeijer009 | 1 | 1 | 3m 43s | -123 |
Items per page:
10
1 – 10 of 12
APFIVE