0
#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

2
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by Se7Olutionyg
0

#include <fstream>
Proofread your code
for missing semicolons (at the end of the enum definition and several other places).

and spelling errors "accoutn" and "shoudDisplay"

0

after correct those stuuf, it successfully compiled. However, it does not run...

You don't seem to be trying very hard. It runs for me.

0

you don't know what I means, It successfully compiled. but it just closed the window when it runs

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.