Fortunately, learning how to do so isn’t too difficult. In this article, you’ll learn how to calculate simple interest and compound interest using Python, C++, and JavaScript.
How Do You Calculate Simple Interest?
Simple interest is a method to calculate the amount of interest charged on a principle amount at a given rate and for a given period of time. You can calculate the simple interest by using the following formula:
The Problem Statement
You’re given principle amount, rate of interest, and time. You need to calculate and print the simple interest for the given values. Example: Let principle = 1000, rate = 7, and timePeriod = 2. Simple Interest = (principle * rate * timePeriod) / 100 = (1000 * 7 * 2) / 100 = 140. Thus, the output is 140.
The C++ Program to Calculate Simple Interest
Below is the C++ program to calculate simple interest:
Output:
The Python Program to Calculate Simple Interest
Below is the Python program to calculate simple interest:
Output:
The JavaScript Program to Calculate Simple Interest
Below is the JavaScript program to calculate simple interest:
Output:
How to Calculate Compound Interest
Compound interest is the addition of interest to the principal amount. In other words, it’s interest on interest. You can calculate the compound interest by using the following formula:
The Problem Statement
You’re given principle amount, rate of interest, and time. You need to calculate and print the compound interest for the given values. Example: Let principle = 1000, rate = 7, and timePeriod = 2. Amount= P(1 + R/100)T = 1144.9 Compound Interest = Amount - Principle Amount = 1144.9 - 1000 = 144.9 Thus, the output is 144.9.
The C++ Program to Calculate Compound Interest
Below is the C++ program to calculate compound interest:
Output:
The Python Program to Calculate Compound Interest
Below is the Python program to calculate compound interest:
Output:
The JavaScript Program to Calculate Compound Interest
Below is the JavaScript program to calculate compound interest:
Output:
Learn to Code for Free: Start With Simple and Compound Interest
Nowadays, the impact of coding is increasing exponentially. And in line with this, the demand for proficient coders is increasing exponentially too. There’s a misconception among the people that they can learn to code only after paying a high fee. But that’s not true. You can learn to code absolutely for free from platforms like freeCodeCamp, Khan Academy, YouTube, and so on. So, even if you don’t have a big budget, you don’t need to worry about missing out.