Question: JavaScript (No PHP) Metro Bank Mortgage Calculator You've been hired to do some programming for Metro Bank. They want you to create a program to

JavaScript (No PHP)

Metro Bank Mortgage Calculator

You've been hired to do some programming for Metro Bank. They want you to create a program to calculate loan payments. The user will enter the amount of money to borrow from the bank, the annual interest rate percentage (that will be compounded monthly) and the number of years to pay back the loan. The program will then display the monthly payment and the total amount of interest that will be paid.

Formulas & Code Specifications

Here are the formulas you will use.

Periodic Payment: Let

A = amount of the loan r = interest rate per period (for this calculation, 1 period is 1 month) n = the number of periods (i.e. the number of months)

Then the formula to find the monthly payment is:

JavaScript (No PHP) Metro Bank Mortgage Calculator You've been hired to do

Remember, when doing calculations with percentages, you need to use the decimal equivalent. So given a percentage rate of 7.5% you want to use the value 0.075.

Total Interest Paid:

Let

P = the monthly payment n = the number of months A = amount of the loan

Then the formula to find the total interest is:

Total Interest = nP - A

------------------

This is the php that I started with, that can be used to convert to javascript...no php

--------LoanCal.php----------

Product Discount Calculator

Loan Calculator

Loan Amount
Interest Rate (annual %)
Period in years

if ($loanAmount && $annualRate && $periodInYears) { // Check if these values are valid. $monthRate = $annualRate / 12 / 100; //Start to do your work here. Don't use operator '**'. //Convert years to months(periods) $numberOfPeriods = $periodInYears * 12; //Calculating numerator of the formula i.e A*r $numerator = $loanAmount*$monthRate; //Calculating denominator of the formula i.e (1 - pow((1+r),(-n))) $denominator = (1 - pow((1 + $monthRate), -($numberOfPeriods))); //Calculating Monthly Payment i.e numerator/denominator $payment = round($numerator/$denominator, 2); //Calculating Total Interest i.e nP-A $totalInterest = $numberOfPeriods * $payment - $loanAmount; ?>

Your Loan Details

Loan Amount: ";?>
Annual Rate: ";?>
Loan Period: ";?>
Monthly Payment: ";?>
Total Interest: ";?>

payment -Ar

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!