Compound Interest

Objective

To implement a program that calculates compound interest. 

 

Theory

Compound interest is the interest calculated on the principal and the interest accumulated over the previous period. It is the most used concept in our daily existence. Compound interest finds its usage in most of the transactions in the banking and finance sectors and other areas. Some of its applications are: 

  1. Calculation of equated monthly instalment (EMI). 
  2. The growth of bacteria. 
  3. Increase or decrease in the value of an item. 

 

Equation for finding total amount using compound interest is as follow: 

                   Total Amount = P(1+r/100)tp 

P = Principal value 

tp = Time period for which Principal value is invested in years

r = Rate of interest per annum

 

Instructions

The program to compute the compound interest and its equivalent low-level language instructions executed by the hardware are given below: 

add It adds the values contained in the register and stores the result in the first register.   
assign It assigns a value to a variable. 
div It divides the values contained in two registers and puts the result in the first register. 
if_false     Checks if the condition evaluated to be false. 
if_true Checks if the condition evaluated to true. 
in It reads the input from the user and stores it in a variable. 
incr It increases the value contained in the register by 1. 
label Is used to mark the position in the Low-level Language Instructions to enable jumping to the marked   position. 
load It loads a value of a global or local variable to the given register. 
lte Lesser than or equal to operator, check whether the first operand is lesser than second   operand and return a Boolean value based on the condition.
mul It multiplies the values contained in two registers and puts the result in the first register. 
out It prints the output value to the screen. 
store It stores the value from the given register to the global or local variable. 
exit Signifies the end of program. 

 

Variables used in the Python program

  • n- Initial investment or principal amount. 
  • r- Annual interest rate (as an integer, not a percentage). 
  • y- Number of years. 

 

Learning Outcomes

  • This program serves as a learning tool for students, particularly those learning about basic financial concepts and programming. 
  • Learn how to use the input() function to get user input. 
  • Understand the importance of converting input values to the appropriate data type using int() function. 
  • Grasp the concept of a for loop and its syntax. 
  • Helps to recognize the order of operations in mathematical expressions. 
  • Learn how to update a variable within a loop to simulate iterative calculations. 
  • Gain exposure to the concept of compound interest and how it affects the growth of an investment over time.