+ 1
In java int /int is always an int how can i get a double value when input2 int value example if i enter 1/2 i will get 0.5
can i get a doble value while i input 2 int like 1/20 is 0.5 if yes them how.
2 Respostas
+ 5
Just cast either the numerator or the denominator to double.
System.out.print((double)1/20);
Another way,
System.out.print(1/20.0);