Simple Interest is mostly used in the baking sector to calculate the interest on loans. The formula used to find the simple interest is SI = p * n * r
Where p stands for Principal Amount, n stands for Number of years and r stands for Rate of interest
For example, suppose we take a loan of the amount 10000 with an interest rate of 10% for 1 year. Then calculating the simple interest by the formula (p*n*r)/100 gives (10000 * 10 * 1) / 100 = 1000. so we have to give 1000 as interest for 1 year.
Now apply this logic in the php programming language. We accept the values for the principal amount, interest rate, and time in years using the function in php language. Then we calculate the interest by using the formula ( p * n * r ) / 100.
In this program, we are using the direct method to calculate the Simple Interest which is using the formula. First, we have to accept the Principal Amount, Number of years, and Rate per annum from the user and assign it to variables p, n, r and use the formula (p * n* r) /100 and assign the result into variable si. And print the value of the variable si as the simple interest.
Step 1: Accept the Principal Amount, Number of years, and Rate per annum into the variables p, n, r
Step 2: Assign the computed value of '(p * n * r) / 100' into the variable si
Step 3: Print the value of the variable si as the simple interest
<?php $p = readline("Enter the Principal Amount: "); $n = readline("Enter the Number of years: "); $r = readline("Enter the Rate per Annum: "); $si = ($p * $n * $r) / (100); echo ("Simple Interest is: $si"); ?>
Enter the Principal Amount: 25000 Enter the Number of years: 2 Enter the Rate per Annum: 10 Simple Interest is: 5000