In: Computer Science
Write a javascript program that computes the total cost for a five year car lease. The program starts with a monthly leasing amount and a yearly increase in percent. The program then outputs the total amount paid for each year and the total overall cost of the lease.
monthly_amount = window.prompt("Enter Monthly Amount: ");
yearly_increase = window.prompt("Enter Yearly
Increase Percentage: ");
total = 0;
total_amount = [];
initial_amount = monthly_amount * 12;
yearly_amount = initial_amount;
for(i = 0 ; i < 5 ; i++)
{
interest = (yearly_amount * 1
* yearly_increase) / 100;
total_amount[i] =
yearly_amount + interest;
yearly_amount = yearly_amount
+ interest;
document.write("Total amount
paid for year "+ i +"\t is \t" ,total_amount[i]);
total +=
total_amount[i];
}
document.write("Total cost for 5 year car lease
is : ",total);