Closed irunestone closed 4 years ago
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 Kramer_CS1050_2020_Fall on page topic-1-4-assignment by user chogan9@msudenver.edu chogan9@msudenver.edu 1.4.8 requires an answer of 10, but the correct answer is 11.5.