0

Loan calculator

Result of my code matched with needed answer but still it doesn’t accept my code: int months = 6; while(months > 0){ amount = (int)Math.floor(amount * 0.9); System.out.println(amount); months--; } Why so? Can someone tell me please?:)

2nd Jan 2021, 6:17 PM
Max Valchyshen
Max Valchyshen - avatar
3 Respostas
+ 2
oh, i see.. tnx
3rd Jan 2021, 8:06 AM
Max Valchyshen
Max Valchyshen - avatar
+ 1
You should check the test results in more detail. Compare your output with the expected output. You are printing several amount (in each loop cycle) but you should only print the final result.
2nd Jan 2021, 8:47 PM
Tibor Santa
Tibor Santa - avatar
0
Use 90% for 6 months to find the balance. 4 lines of code added. https://code.sololearn.com/cp6GXE4Rc84v/?ref=app If you are paying 10% every month, one way is to find the 10% and then use your total minus the 10% paid to get the balance. The other way, is to find the 90% so you don't have to minus. If you have 100 and you paid 10%, Method 1: 100 - (100 * 10%) = 90 Method 2: 100 * 90% = 90 The "i=0" is used for looping. It will loop from 0 until 5 (< 6), which is 6 times. Finally prints out amount.
16th Jan 2021, 4:25 AM
Lam Wei Li
Lam Wei Li - avatar