Infolinks

Breaking

Adsense

Saturday, January 30, 2016

SIMPLE INTEREST CALCULATOR: Solve the Interest in PHP

Simple interest calculator allows us to solve for the value of I, which is the interest earned or charged on a loan. According to the formula, P is the principal, R is the annual rate in decimal form and T is the loan period which is express in years.

This simple interest calculator will solve for the initial deposit together with the interest after a certain period of time. You can use this program especially if you want to solve for the total remaining payable from a certain loan.

Formula Accrued Amount

A = P(1 + RT)

where

A = Acrued Amount (Principal + Interest)
P = Principal
R = Rate
T = Time

First thing to do is to convert the rate into percent. Let's say the interest per year is 5%, then we need to convert it to decimal by dividing by 100 and the result is 0.05. And remember that the time should be expressed in years.

PHP and HTML Code


<form method="post">
P <input type="text" name="p" placeholder="Enter Principal Amount"><br>
R <input type="text" name="r" placeholder="Enter percent rate"><br>
T <input type="text" name="t" placeholder="Enter Number of years"> year/s<br>
<button name="display" type="submit">Display</button>
</form>

<?php
if (isset($_POST['display']))
{
$principal=$_POST['p'];
$r=$_POST['r'];
$rate=$r/100;
$time=$_POST['t'];

$A=$principal*(1+$rate*$time);
echo "$A is the accrued amount of $principal after $time years with $r % interest";
}
?>

Output






Try our Simple Interest Calculator Using PHP Here



Thank you for visiting and hope this helps you. Feel free to leave a comment below for any questions. I got some other articles related to php and mysql here in my blog. Watch out for more upcoming tutorials related to blogging and programming. Good day! ^_^

SIMPLE INTEREST CALCULATOR: Solve the Interest in PHP

No comments:

Post a Comment

Adbox