Closed irunestone closed 4 years ago
This question and answer is correct. Because a and b are int's, a/b is truncated and returned as an int (2 instead of 2.5). Try the code in an active code area or the scratch area (pencil icon at the top right) and you will see that the answer is 10. public class Test1 { public static void main(String[] args) { int a = 5; int b = 2; double c = 3.0; System.out.println(5 + a / b * c - 1); } }
Error reported in course CS_Awesome_Algonquin on page topic-1-4-assignment by user 21osetek 21osetekl@nsboroschools.net The last problem says the answer is 10 when it's really 11.5 on my computer at least.