Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose that you have a $20,000 loan at 5.5 percent annual interest compounded m

ID: 3886393 • Letter: S

Question

Suppose that you have a $20,000 loan at 5.5 percent annual interest compounded monthly. You can afford to pay $100/month toward this loan. How long will it take until the loan is paid off? To do this calculation, think of the amount remaining on the loan from time k to time k+1 as a combination of interest accrued and payment made, express this as an iteration, and then write code using a for –next loop to find the amount remaining in the loan after N months. You may need to experiment with the value of N to find the value in which the remaining amount passes through zero (and the loan is paid off).

Use Macros in Excel.

Explanation / Answer

/**
*
* @author Veerendra Patel
*/
public class NewClass1
{
//Main function
public static void main(String[] args)
{
//Variables declaration, based on the given values
double startCredit = 20000;
double interestRate = 5.5/(12*100);

double payInterest = startCredit * interestRate;
double payDebt = startCredit - payInterest;
double paid = payInterest + payDebt;
double newCredit = 19909;
int months = 0;
double interest = 5.5/(12*100), payment = 100, debt = 20000;
//Use a while loop: as long as there is a debt to
// be paid off, calculate the new amount of debt
//while the monthly interest, subtract the
//monthly payment, and increment the month
//counter
while (debt > 0)
{
payInterest = newCredit * interestRate;
debt += debt * interest;
debt -= payment;
months += 1;
System.out.println("Debt remaing:"+debt);
}//End while

System.out.printf("It will take" + months + " months to pay off the given loan.");
  

}//End main

}//End class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote