How to crate a code for compound interest? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to crate a code for compound interest?

13th Nov 2016, 3:39 AM
Kartik Rao
Kartik Rao - avatar
2 Answers
+ 3
for (int x = 0; x < years; x++) { money *= 1.02 // For two percent interest rate }
13th Nov 2016, 3:50 AM
Keto Z
Keto Z - avatar
+ 1
Yup, basic maths. To add or subtract a percentage of a number to itself: Positive percentage, Money * (1 + (<Percentage> / 100) Negative percentage, Money * (1 - (<Percentage> / 100)
13th Nov 2016, 4:12 AM
Cohen Creber
Cohen Creber - avatar