volume_mute
What is the result of the following calculation?
publish date: 2020/09/01 21:32:00 GMT+10
volume_mutepublic class Ex {
public static void main(String[] args) {
System.out.println(5 + 15 / 3 * 2 - 8 % 3);
}
}
Missing Word
Correct Answer
13
Explanation
Solve the equation for % (mod), / (division) then * (multiplication)
5 + 15 / 3 * 2 - 8 % 3 (1)
8 % 3 = 2 (% calculates the remainder of the division where the result of division of 8/3 is 2 and the remainder is 2)
15 / 3 = 5 (normal division)
replace calculated results in the equation to have
5 + 5 * 2 - 2 (2)
Calculate 5 * 2 = 10 and replace in equation (2)
5 + 10 - 2 = 13