Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 19th, 2005, 2: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 3:52 PM. Reason: changed title
bliznags is offline   Reply With Quote
Old Mar 19th, 2005, 4:16 PM   #2
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Umm... if you are going to print bold lines you need to figure out how to set your console into a formatted text mode. A regular console is not actually capable of just displaying bolded text via a printf... what you need to do is call the appropriat ASM code to initialize your console in the correct mode... I forget the name of the mode, but the interrupt I believe is 13h, just look up the AX/AH value. Once you have initialized the console I believe the default memory location where you start to write text is 0xA000 or 0xB000 (been a long time since I have done this).
__________________
Clifford Matthew Roche &lt;geek@cliffordroche.com&gt;
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Mar 19th, 2005, 4:44 PM   #3
bliznags
Newbie
 
Join Date: Mar 2005
Location: Bethany Beach, DE
Posts: 10
Rep Power: 0 bliznags is on a distinguished road
no, i dont need to print those statements out in bold. i need help figuring out the actual loop to get those amounts printed. i simply put those lines in bold b/c i need help with them.
bliznags is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:06 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC