Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions