0
why is this 12.0 instead of 12.5, i did the math on calc comes out to 12.5
int x, y; double z; x = 5; y = x * 2; z = x/2 + y; System.out.print(z);
4 Antworten
0
There fore, to get the required result, your variable x should also be a double, and not int
0
x is an integer.
When you do x/2 the output is 2, (as opposed to 2.5) because the integer cannot store decimal values.
0
thanks!!
0
You're welcome 😁