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?
You must be signed in to leave a comment
5 September 2020, 00:52
Thank you for the clarification!
4 September 2020, 14:09
Remember that the result of 9/5 is 1. When you divide integers in Java, they give INTEGER as the result. You have to typeor if you want to have 1.8 as a result.
4 September 2020, 05:33
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