Menu

[Solved]Javascript Instructions Attached Code Bottom T Figure Error Get Work Design Implement Prog Q37220458

****(JAVASCRIPT)****

INSTRUCTIONS and ATTACHED MY CODE AT THE BOTTOM. I can’tfigure out my error or how to get this to work!

Design and implement a program that will allow us to determinethe length of time needed to pay off a credit card balance, as wellas the total interest paid.

The program must implement the following functions:

1. displayWelcome

This function should display the welcome message to the userexplaining what the program does.

2. calculateMinimumPayment

This function calculates the minimum payment. It should takebalance and interest rate as arguments and return the minimumpayment.

So the value you display for minimum payment is the value youget from this method. Do not use a literal hardcoded value when youdisplay the minimum payment!

3. displayPayments

This function displays the actual payment schedule. It shouldtake the balance, monthly interest rate and minimum payment asarguments.

Use the 1500, 18% and 2% literal values below.

See the sample execution below:

This program will determine the time to pay off a credit cardand the interest paid based on the current balance,

the interest rate, and the monthly payments made.

Balance on your credit card: 1500

Interest Rate: 18

Assuming a minimum payment of 2% of the balance ($20 min)

Your minimum payment would be $ 30.00

PAYOFF SCHEDULE

_________________

Year Balance Payment Num Interest Paid

1 1,492.50 1 22.50

1,484.89 2 44.89

1,477.16 3 67.16

1,469.32 4 89.32

. . .

. . .

7 517.51 73 1,207.51

495.28 74 1,215.28

472.70 75 1,222.70

449.79 76 1,229.79

. . .

. . .

8 227.51 85 1,277.51

200.92 86 1,280.92

173.94 87 1,283.94

146.55 88 1,286.55

118.74 89 1,288.74

90.53 90 1,290.53

61.88 91 1,291.88

32.81 92 1,292.81

3.30 93 1,293.30

0.00 94 1,293.35

____________________________________________________

HERES THE CODE I HAVE SO FAR:

// Create welcome function
function displayWelcome()
{
console.log(“Welcome! nThis program will determine the time to payoff a credit card and the interest paid based on the currentbalance, the interest rate, and the monthly payments made.n”)
}

// Create function that calculates minimum payment based onbalance, interest rate, and monthly payments
function calculateMinimumPayment(balance,minimumPayPercentage)
{
var creditBalance = balance * minimumPayPercentage;
if (20 > creditBalance)
{
return 20;
}
else
{
return creditBalance;
}

}

var id = 1;
// Create function for paymentid
function generatePaymentID()
{
return id +=1;
}

// Create function that displays payment schedule
function processPaymentSchedule(balance,interest,minimumPay)
{

console.log(“Balance on your credit card: $” +balance.toFixed(2))
console.log(“Interest Rate: ” + (interest * 100) + “%”)
console.log(“Assuming a minimum payment of 2% of the balance ($30min)nYour minimum payment would be: $”+minimumPay.toFixed(2))
console.log(“n________________________________________n PAYOFFSCHEDULE:n”)
console.log(“YeartBalancett Payment #tInterest Paid”)

// Define Variables

var year = 1;
var interestPaid = 0;
var paymentID = 0;

// Start loop
while(balance>0)
{

// Calculate interest paid
interestPaid += balance*interest/12;

// Calculate principal paid
balance = balance – ( minimumPay + balance*interest/12);

// Call the generatePaymentID to set paymentID
generatePaymentID();
{
console.log(year+”t$”+balance.toFixed(2)+”tt”+id+”t$”+interestPaid.toFixed(2));
}

// Increment the year
if (paymentID % 12 ===0)
{
paymentID +=1;
}
if (balance < 0 )
{
balance = 0;
}
}

}
// Create variables
var currentBalance = 1500;
var minimumPayPercentage = 0.02;
var interest = 0.18;

// Call the display function
displayWelcome();

// Call the function to calculate minimum payment
var minimumPay =calculateMinimumPayment(currentBalance,minimumPayPercentage);

// Call the funtion to display payments
processPaymentSchedule(currentBalance,interest,minimumPay);

Expert Answer


Answer to ****(JAVASCRIPT)**** INSTRUCTIONS and ATTACHED MY CODE AT THE BOTTOM. I can’t figure out my error or how to get this to… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *