How to get quotient with decimals | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to get quotient with decimals

In Java: System.out.println(31/7); gives me "4" Assigning it to a double variable first makes no sense either. double x = 31/7; System.out.println(x); gives me "4.0" However the correct answer should be 4.42 How can I make it output 4.42?

4th Mar 2020, 8:19 AM
ใ‹ใ‚“ใงใ‚“
ใ‹ใ‚“ใงใ‚“ - avatar
1 Answer