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:

10000

Enter an annual interest rate:

12

Your first month of interest will be $100.00

Enter the amount of your monthly payment:

200

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:

Code:

#include <stdio.h>
int main(){
double principal, interest_rate, payment, payments, total_interest;
printf("Enter a principal amount:\n");
scanf("%lf", &principal);
printf("Enter an annual interest rate:\n");
scanf("%lf", &interest_rate);
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");
scanf("%0.2lf", &payment);
printf("You borrowed: %0.2lf\n" principal);
while(
{
}
}

i have been plugging things into the while loop, and have tried numerous for loop combinations but nothing works for me.