#include <iostream>
using namespace std;
#include <iomanip>
#include <cstdlib>
enum RequestType { ZERO_BALANCE = 1 , CREDIT_BALANCE, DEBIT_BALANCE,END}
int getRequest();
bool shouldDisplay ( int, double);
void outputLine ( int, const char*const, double);
int main ()
{
ifstream inClientFile( "clients.txt", ios::in);
if ( !inClientFile)
{
cerr << " File could not be opened " << endl;
exit (1);
}
int request;
int account ;
char name [30];
double balance;
request = getRequest();
while ( request !=END)
{
switch (request)
{
case ZERO_BALANCE :
cout << " \nAccounts with zero balance : \n";
break;
case CREDIT_BALANCE:
cout << " \nAccounts with credit balances : \n " ;
case DEBIT_BALANCE :
cout << " \nAccounts with debit balance :\n ";
break
}//end swtich
inClientFile >> account >> name >> balance;
while (!inClientFile.eof())
{
if ( shouldDisplay (request,balance))
outputLine (account,name,balance);
inClientFile >> account>> name>>balance;
}
inClientFile.clear();
inClientFile.seekg(0);
request = getRequest();
}
cout << " End of run. " << endl;
return 0;
}
int getRequest ()
{
int request;
cout << "\n Enter request " << endl
<< " 1 - List accounts with zero balances " << endl
<< " 2 - List accounts with credit balances " << endl
<< " 3 - List accounts with debit balances " << endl
<< " 4 - End of run " << fixed << showpoint;
do
{
cout << "\n ? " ;
cin >> request ;
} while ( request < ZERO_BALANCE && request > END)
return request;
}
bool shoudDisplay ( int type, double balance )
{
if ( type == CREDIT_BALANCE && balance < 0 )
return true ;
if ( type == DEBIT_BALANCE && balance > 0 )
return true ;
if ( type == ZERO_BALANCE && balance == 0 )
return true;
return false;
}
void outputLine ( int account, const char * const name,double balance)
{
cout << left << setw (10 ) << accoutn << setw(10) << account << setw(13)<<name
<< setw(7) << setprecision(2)<< right << balance << endl;
}
I dont' know why it does not run
this is the mistake
6 F:\C++\Class\List account.cpp new types may not be defined in a return type