+ 1
Why this java code result is 0
int c = (300-315); float g = c/300; System.out.println("percentage of salary changes is : " + g);
1 Réponse
+ 9
Both c and 300 are integer, so their quotient is also integer. You may use any of the following ways to convert the quotient into float or double:
1. float g = c/300.0f;
2. double g = c/300.0;
3. double g = (double) c/300;