How to Calculate Simple Interest with Example in PHP
ADVERTISEMENTS
How to calculate simple interest with example in PHP.
In this article, you will learn how to calculate simple interest with examples in PHP.
Example
Principal = 5
Time = 7
Rate = 9
Simple Interest = 3.15
Simple Interest Formula
SI = (P * T * R) / 100
Source Code
<?php
// How to Calculate Simple Interest with Example in PHP
$p = 5;
$t = 7;
$r = 9;
$SI = NULL;
// $p=principal, $t=time, $r=rate, $SI=simple interest
// It will calculate the simple interest
$SI = ($p * $t * $r) / 100;
// It will print the final output
echo "Simple Interest = " . $SI;
?>
Output
Simple Interest = 3.15
Explanation
In this given program we have taken input variables named with their values $p = 5
, $t = 7
, and $r = 9
. After that, we applied the standard formula to calculate the simple interest.
Then It will return the 3.15
simple interest of the above program.