![]() |
Trouble with while loop.
Hi. I am new to this forum. I have written a program to calculate the outstanding balance, interest payment, and principal payment for a loan. When I compile it does not display any results. I believe the error is in my while loop but I have not had any luck locating the error.
:
int main()I would appreciate any help that I can get. |
So, in your loop, you have the cout with lots of formatting stuff, but you don't actually output anything. I'm guessing that's your problem.
Side note: when copmaring floating point numbers, using < and > is a bit risky, since they aren't stored precisely in memory. It is possible that 80000.0 on some machines may be stored as slightly larger or smaller, which could result in the loop never being run. One way around this is to use a tolerance level, e.g. :
double epsilon = 0.05; // tolerance levelPS - Welcome to the forum :D |
To output the information do I need to include it in the while loop or before.
|
You need to cout the data. Like this:
:
cout << setiosflags(ios::fixed) |
Thanks so much. I made the changes that you suggested and now it is running right.
|
| All times are GMT -5. The time now is 1:39 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC