I'm a beginner in Java programming. When I coded a simple console app it gave an output which was not what I wanted. My code is:
class myClass{
public static void main(String[] args) {
int ballsPlayed = 100;
double o = (double)(( ballsPlayed / 6 ) + ( ( ballsPlayed % 6) / 10 ));
System.out.println(o);
}
}
( ( ballsPlayed % 6) / 10) should be 0.4 since remainder of 100/6 is 4 and 4/10 must give 0.4. Then the variable 'o' must give 16.4(16+0.4). But I am getting 16.0 as an output from console. What is the mistake I committed?
double ballsPlayed = 100;