You take a loan from a friend and need to calculate how much you will owe him after 6 months. You are going to pay him back 10% | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

You take a loan from a friend and need to calculate how much you will owe him after 6 months. You are going to pay him back 10%

Use loops to calculate payments and integers for amounts

19th Dec 2020, 11:24 AM
witness nkge
4 Answers
+ 1
Considering you borrowed $1000 At the end of year you must pay $1100 So you would pay $100 more Interest for every month = 100/12 So interest for 6 months = (100/12)*6 Total payable = $1000 + $(100/12)*6
19th Dec 2020, 2:41 PM
Avinesh
Avinesh - 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:33 PM
Lam Wei Li
Lam Wei Li - avatar
0
Can you write the code Avinesh ?
22nd Dec 2020, 4:28 AM
Dhaval Dodiya
Dhaval Dodiya - avatar
0
Dhaval Dodiya I can but I won't until there is a genuine attempt by the user.
22nd Dec 2020, 5:01 AM
Avinesh
Avinesh - avatar