0

(Solved)HELP - Loan Calculator in Java

The code I made for the Loan Calculator question in the java course doesn't work in the last 3 test cases. Can anyone explain to me why? https://code.sololearn.com/cjtoOq0Px25o/?ref=app

14th Jun 2021, 1:02 AM
Érika đŸ‘»
Érika đŸ‘» - avatar
2 Answers
+ 11
pay = amount/100.0*10; Pay is 0 (truncated) when amount becomes less than 100 System.out.println(50/100*10);//returns 0 System.out.println(50/100.0*10);//returns 5
14th Jun 2021, 1:22 AM
Simba
Simba - avatar
+ 3
Érika đŸ‘» keep it as double only just change to int while printing and use math.ceil and math.round function too
14th Jun 2021, 3:27 AM
Atul [Inactive]