Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 1: Primitive Types
Start Practice TestPractice Test
About Exam
medium Solved by 14 students

Java Arithmetic Expression Evaluation

Mark
< Prev
Next >

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) returns 10.0.
  • A call to calculateExpression(6, 3, 2) returns 9.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) + a / c;

D

double result = (a * b) / c;

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#110818526533 0m 18s 282
#2zhenmunse11 0m 00s 100
#3busemagngr11 0m 22s 78
#4liuwilliam07241011 0m 28s 72
#5lsj0803092211 0m 42s 58
#6raufyildirim9511 0m 46s 54
#7hmbin99911 0m 58s 42
#8parth.taur22711 1m 04s 36
#9sarah.alyahya90tt01 0m 00s -10
#10Wilbert.Ankomah2701 0m 26s -36
Items per page:
10
1 – 10 of 16

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|