int main(){ AccountNumber myNumber; char name[41]; int bankCode; int branchCode; int accNumber; cout << "Bank account app" << endl << "===================" << endl << endl; cout << "Please enter your name: "; cin >> name; cout << "Please enter your bank account and branch codes," " and your account number, separated by spaces." << endl << "999 999 9999: "; cin >> bankCode >> branchCode >> accNumber; myNumber.setName(name); myNumber.setAccountNumber(bankCode, branchCode, accNumber); if (!myNumber.isValid()){ cout << "The account number entered is invalid." << endl << "please use the following format: 999 999 99999" << endl << endl; } myNumber.display(); return 0; }
int main(){ AccountNumber myNumber; char name[41]; int bankCode; int branchCode; int accNumber; cout << "Bank account app" << endl << "===================" << endl << endl; cout << "Please enter your name: "; cin >> name; cout << "please enter your bank account ,branch code" << ", and account number as follows:" << endl << "999 999 99999: "; do{ cin >> bankCode >> branchCode >> accNumber; myNumber.setName(name); myNumber.setAccountNumber(bankCode, branchCode, accNumber); displayAccountNumber(&myNumber); } while (!myNumber.isValid() && cout << "Invalid account number, (999 999 9999), try again: "); cout << "Thank you!" << endl; return 0; }
int ProcessAccounts( int argc, char ** argv ) { char *pBuf = NULL; const int BUFSIZE = ANMETRICS_WIDTH * MCMETRICS_WIDTH * MCMETRICS_LINEHEIGHT; FILE *pF = NULL; int accountsProcessed = 0; char outBuf[ ANMETRICS_WIDTH + 1 ]; AccountNumberRow accountNumberRow; AccountNumber accountNumber; ::memset( outBuf, 0, sizeof( outBuf ) ); // Validate commandline arguments; enforce exactly two if( argc < 2 || argc > 2 ) { // Invalid; print usage banner PrintUsage(); return 0; } else { // Open the file and begin parsing pF = fopen( ( char * ) argv[1], "r" ); if( pF ) { // Here we read one macrorow's worth of data. // That means, per the requirements, 3 columns * 9 account digits * 4 rows // // (per Steve Maguire's Writing Solid Code, make constant L-value) while( ANR_ERR_SUCCESS == accountNumberRow.Read( pF ) ) { ErrBuf errBuf; switch( accountNumber.Parse( accountNumberRow.GetBuf(), outBuf, sizeof( outBuf ) ) ) { // Handle error logging case AN_ERR_SUCCESS: // Do nothing break; default: SNPRINTF( errBuf.data(), errBuf.max_size(), "Record %d has errors", accountsProcessed + 1 ); Logger::LogErr( errBuf.data() ); break; } printf( "%s\n", outBuf ); accountsProcessed++; } } else { Logger::LogErr( "File not found" ); } } // clean up here // summarize if( accountsProcessed ) { printf( "\n=== SUMMARY ===\n %d Account numbers processed\n", accountsProcessed ); } return 0; }