I have been to use a simple loop to count the number of months it takes to pay off a loan, and it should look like this:
Enter a principal amount:
Enter an annual interest rate:
Your first month of interest will be $100.00
Enter the amount of your monthly payment:
You borrowed: $10000.00
Your payment schedule consists of 69 payments of $200.00
and a final principal payment of $131.06.
The total amount of interest you pay will be $3931.06.
i have figured out how to do everything except the last three lines. i know how to make math formulas up to calculate it but I am supposed to use a "simple loop" to do it instead. i dont know how to make the loop to figure out the total payments, final principal payments, and total interest.
Here is what i have:
i have been plugging things into the while loop, and have tried numerous for loop combinations but nothing works for me.
double principal, interest_rate, payment, payments, total_interest;
printf("Enter a principal amount:\n");
printf("Enter an annual interest rate:\n");
printf("Your first month of interest will be: %0.2lf\n", (12 / interest_rate * .01) * principal);
printf("Enter the amount of your monthly payment:\n");
printf("You borrowed: %0.2lf\n" principal);