Javascript Assignment 3: 75 points Design and implement a program that will allo
ID: 3572026 • Letter: J
Question
Javascript
Assignment 3:
75 points
Design and implement a program that will allow us to determine the length of time needed to pay off a credit card balance, as well as the total interest paid.
The program must implement the following functions:
displayWelcome
This function should display the welcome message to the user explaining what the program does.
calculateMinimumPayment
This function calculates the minimum payment. It should take balance and minimum payment rate as arguments and return the minimum payment.
So the value you display for minimum payment is the value you get from this method. Do not use a literal hardcoded value when you display the minimum payment!
displayPayments
This function displays the actual payment schedule. It should take the balance, monthly interest rate and minimum payment as arguments.
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 card and 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
Explanation / Answer
i am pasting the code
public class CreditcardPayment {
static void displayWelcome()
{
System.out.println("This program will determine the time to pay off a "
+"credit card and the interest paid based on the current balance, "
+ "the interest rate, and the monthly payments made");
}
static double calculateMinimumPayment( double Balance, double MinPaymentRate)
{
double MinPayment = (Balance*MinPaymentRate)/100;
if(MinPayment<20)
{
MinPayment=20;
}
return MinPayment;
}
static void dsiplayPayments( double Balance,double Intrest, double MinPaymentRate)
{
double minpayment = calculateMinimumPayment(Balance,MinPaymentRate);
System.out.println("Balance on your credit card: "+ Balance);
System.out.println("Interest Rate: "+ Intrest);
System.out.println("Assuming a minimum payment of "+MinPaymentRate+" % of the balance ($20 min)");
System.out.println ("Your minimum payment would be $ "+minpayment );
System.out.println("PAYOFF SCHEDULE");
System.out.println("-------------------");
System.out.println("Year Balance Payment Num Interest Paid");
int counter = 0;
double totalintrest = 0;
while(true)
{
double montlyIntrest = (Balance*Intrest)/1200.0;
minpayment = calculateMinimumPayment(Balance,MinPaymentRate);
Balance = Balance+montlyIntrest-minpayment;
totalintrest+=montlyIntrest;
if(Balance<0)
{
break;
}
System.out.println(((counter/12)+1)+" "+
String.format("%.02f", Balance) +" "+
((counter%12)+1) +" "+
String.format("%.02f", totalintrest));
counter++;
}
}
public static void main(String[] args)
{
displayWelcome();
dsiplayPayments(1500,18,2);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.