View Single Post
Old Mar 19th, 2005, 3:39 PM   #1
bliznags
Newbie
 
Join Date: Mar 2005
Location: Bethany Beach, DE
Posts: 10
Rep Power: 0 bliznags is on a distinguished road
need help with a loop

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 lines in bold. 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:

#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. any help will be greatly appreciated.

Last edited by bliznags; Mar 19th, 2005 at 4:52 PM. Reason: changed title
bliznags is offline   Reply With Quote