I managed to do it but I am just wondering why it had to be 5.0 for it to work. I did very poorly in maths when I was in school so a simple explanation would be very much appreciated. Thanks!
Why 5.0 instead of 5?
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Valuev Nutt
5 September 2020, 00:52
Thank you for the clarification!
0
Mariam
4 September 2020, 14:09useful
Remember that the result of 9/5 is 1. When you divide integers in Java, they give INTEGER as the result. You have to type
or
if you want to have 1.8 as a result. +2
zimme
4 September 2020, 05:33useful
read about type casting in java. in java if we do some math with int variables, the result will be int. and since we need a decimal result in this task, we treat one of the variables as double by casting
+1