Loan capital Time in years 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Interest 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75 3.00 3.25 3.50 3.75 4.00 4.25 4.75 5.00 Instalment Fixed Annuity

Back to examples

PHP-script

<? /* Author: Jouni Juntunen Date: 8/2009 Description: Read capital, interest, time and instalment from HTML-form and calculates annuity or fixed instalment amortization schedule payment. */ //Read values passed from HTML-form. \$capital=\$_POST[‘capital’]; \$interest=\$_POST[‘interest’]; \$year=\$_POST[‘year’]; \$instalment=\$_POST[‘instalment’]; //Print passed values to page. print “Capital \$capital
“; print “Interest \$interest
“; print “Instalment \$instalment
“; print “Years \$year
“; //Calculate time in months. \$months=\$year * 12; //Check out which is the instalment. if (strcmp(\$instalment,”Fixed”)==0) //Fixed amortization schedule { //Calculate fixed payment for month. \$fixedPayment=\$capital / \$months; \$interestRateForMonth=\$interest / 12; //Calculate interest for every month. for (\$i=0;\$i<\$months;\$i++) { //Interest for the month. \$interestForMonth=\$capital / 100 * \$interestRateForMonth; //Diminish capital after calculating interest. \$capital=\$capital – \$fixedPayment; //Payment for month is fixed pay + interest. \$paymentForMonth=\$fixedPayment + \$interestForMonth; //Print out payment for this month. Output is formatted (payment has two digits) \$month=\$i+1; printf(“\$month payment is %.2f
“, \$paymentForMonth); } } //Annuity else { //Calculate montly pay. \$interest=\$interest / 100; \$result=\$interest / 12 * pow(1 + \$interest / 12,\$months) / (pow(1 + \$interest / 12,\$months) – 1) * \$capital; printf(“Monthly pay is %.2f”, \$result); } ?>
Calculate again
Back to examples