0

Can t do loan calculator

I found a solution to do it but my output is bigger than the actual solution by 1 how can i do it?

18th Dec 2020, 3:57 PM
i changed my name cuz it was cringe
i changed my name cuz it was cringe - avatar
7 odpowiedzi
+ 2
https://code.sololearn.com/cp6GXE4Rc84v/?ref=app The reason why you get 54145 is because of Integer division. It ignores decimals (rounding down). Ultimately when you do a minus, you get an extra 1. 1: 100000 - 100000/10 = 90000 2: 90000 - 90000/10 = 81000 3: 81000 - 81000/10 = 72900 4: 72900 - 72900/10 = 65610 5: 65610 - 65610/10 = 59049 6: 59049 - 59049/10 = 59049 - 5904 (missing precision) = 54145 (extra 1, expected 54144) To bypass, you can do "amount = amount * 90 / 100". Do not hard-code -1 or +1. One good example will be 0. After 6 months, it will still be 0. By hard-coding -1, it results in -1 which is wrong.
16th Jan 2021, 4:46 AM
Lam Wei Li
Lam Wei Li - avatar
+ 4
Pls post your code otherwise how could i tell what's wrong
18th Dec 2020, 4:04 PM
Alphin K Sajan
Alphin K Sajan - avatar
+ 2
Then decrement 1 . Pls post your code here so that we can help .
18th Dec 2020, 4:01 PM
Alphin K Sajan
Alphin K Sajan - avatar
+ 1
When i do solution - 1 the first 2 inputs work with it but the other 3 don t
18th Dec 2020, 4:02 PM
i changed my name cuz it was cringe
i changed my name cuz it was cringe - avatar
+ 1
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.
29th Dec 2020, 6:31 PM
Lam Wei Li
Lam Wei Li - avatar
0
I did it correct after by trying something else but this is still very helpfull thank you
16th Jan 2021, 4:10 PM
i changed my name cuz it was cringe
i changed my name cuz it was cringe - avatar