[Dev-C++] while termination problems
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: fuzzyheadedfreak <fuz...@co...> - 2004-10-06 00:39:08
|
This maybe a newbie question, but consider this while statement. =
The sentential (-1) should terminate at the beginning of the loop, which =
it doesn't. What have I forgotten?=20
#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;
int main(int argc, char *argv[])
{
double acctnum;
double bBal;
double nBal;
double charges;
double limit;
double credits;
=20
while (acctnum !=3D -1){
=20
cout << "Enter account number (enter -1 to end): ";
cin >> acctnum;
=20
cout << "Enter beginning balance: ";
cin >> bBal;
=20
cout << "Enter total charges: ";
cin >> charges;
=20
cout << "Enter total credits: ";
cin >> credits;
=20
cout << "Enter credit limit: ";
cin >> limit;
=20
nBal =3D bBal + charges - credits;
=20
=20
cout << "Account:" << setw(13) << acctnum << "\n";
cout << "Credit Limit:" << setw(9) << limit << "\n";
cout << "Balance:" << setw(14) << nBal << "\n";
=20
if (nBal > limit)
cout << "Credit Limit Exceeded.\n";
=20
}
=20
system("PAUSE");=20
return 0;
}
|