<html> <title>Chapter 6 Assignment 2</title> <head> <script type = "text/javascript"> function calcPayment(monthInt, months, loan){ var base = Math.pow(1+monthInt,months); var payment = (loan*monthInt)/(1-(1/base)); return payment;} </script> </head> <body bgcolor = "lightpink"> <h1>Loan Calculator</h1> <pre> <script type = "text/javascript"> var input = prompt("Enter the vehicle price (Ex:10000):",""); var price = parseInt(input); input = prompt("Enter the down payment amount (Ex: 1000):",""); var down = parseInt(input); input = prompt("Enter the annual interest rate for the loan (Ex:7.5)",""); var interest = parseFloat(input); var loan = price - down; var monthInt = interest/12; document.write("Vehicle Price: $"+price+"<br>"); document.write("Down Payment: $"+down+"<br>"); document.write("Interest Rate: "+interest+"%<br>"); document.write("Loan Amount: $"+loan+"<br>"); var payment = calcPayment(monthInt, 24, loan); document.write("# of Months Payment/month<br>"); document.write(" 24 "+payment+"<br>"); payment = calcPayment(monthInt, 36, loan); document.write(" 36 "+payment+"<br>"); payment = calcPayment(monthInt, 48, loan); document.write(" 48 "+payment+"<br>"); payment = calcPayment(monthInt, 60, loan); document.write(" 60 "+payment+"<br>"); </script> </pre> </body> </html>

This post has been edited by **synlight**: 06 July 2012 - 09:17 AM