![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2005
Location: Bethany Beach, DE
Posts: 10
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
Expert Programmer
|
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 <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Mar 2005
Location: Bethany Beach, DE
Posts: 10
Rep Power: 0
![]() |
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.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|