| preferred AP College board partner for AP classes
medium Solved by 9 students
Java Arithmetic Expression Evaluation
< Prev
Next >

Which of the following statements can replace the /* missing statement */ so that calculateExpression works as intended?
Consider the method calculateExpression, which is intended to compute the result of a mathematical expression involving addition, multiplication, and division.

For example, the following scenarios demonstrate the expected behavior of calculateExpression:

calculateExpression(5, 4, 2) = 10.0
calculateExpression(6, 3, 2) = 9.0

The current implementation of calculateExpression is incomplete:

public static double calculateExpression(int a, int b, int c) {
    /* missing statement */
    return result;
}

Which of the following statements can replace the /* missing statement */ so that calculateExpression works as intended?

A

double result = a * (b - c) + a / c;

B

double result = (a * b) / c;

C

double result = a + b * c - (a / c);

D

double result = a / b * c + a;

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#110818526533 0m 18s 282
#2lsj0803092211 0m 42s 58
#3sarah.alyahya90tt01 0m 00s -10
#4patrickmeijer00911 3m 43s -123
#5y.seong202711 4m 11s -151
#6shelter200200411 6m 10s -270
APFIVE © 2020.
Email: [email protected]|Privacy Policy