Beginners C++ headache

I have been working on getting this code for four days now and cannot figure out what I am doing wrong. I get the complier log down to 2 errors make one change and end up with 32 errors. Please help...

// Text-printing program.
#include <iostream> // allows program to output data to the screen
#include <windows.h>

// function main begins program execution
int main()

{
std::cout << "Jeff Wemple";
std::cout << "INF231";
std::cout << "Professor Reilly";

system("PAUSE");

return 0;
}

#ifndef Clientdatabase_H
#define Clientdatabase_H

#include <string>
using std::string;

class Clientdatabase
{
public:
int getInput() const;
};endif

#ifndef CashDespenser_H
#define CashDespenser_H

#include <string>
using std::string;

class CashDespenser
{
public:
int getInput() const;
};endif

#ifndef Transaction_H
#define Transaction_H

#include <string>
using std::string;

class Transaction
{
public:
int getInput() const;
};endif

#ifndef Keypad_H
#define Keypad_H

#include <string>
using std::string;

class Keypad
{
public:
int getInput() const;
};endif

#ifndef Screen_H
#define Screen_H

#include <string>
using std::string;

class Screen
{
public:
int getInput() const;
};endif

#ifndef Accountdatabase_H
#define Accountdatabase_H

#include <string>
using std::string;

class Accountdatabase
{
public:
int getInput() const;
};endif

#ifndef Withdrawal_H
#define Withdrawal_H

#include <string>
using std::string;

class Withdrawal
{
public:
int getinput() const;
};endif

class Keypad;
class CashDispenser;
class Withdrawl;


#endif // WITHDRAWAL

#include <iostream>
using std::cerr;
using std::cin;
using std::cout;
using std::fixed;
using std::ios;
using std::left;
using std::right;
using std::showpoint;

#include <fstream>
using std::ofstream;
using std::ostream;
using std::fstream;

#include <iomanip>
using std::setw;
using std::setprecision;

#include <cstdlib>
using std::exit;

int enterChoice();
void createTextFile( fstream &readfromfile );
void updateRecord( fstream &readfromfile );
void newRecord( fstream &readfromfile );
void deleteRecord( fstream &readfromfile );


fstream inoutCredit( "credit,dat", ios::in | ios::out | ios::binary );

int Choice();

}
while ( ( Choice = enterChoice() ) != end1 );
{
switch ( choice );
{
case PRINT:
createTextfile( inoutcredit );
break;
case UPDATE:
updateRecord ( inoutcredit );
break;
case NEW;
newrecord ( inoutcredit );
break;
case DELETE;
deleterecord ( inoutcredit );
break;
default:
cerr << "Unable to process transaction" << ;
break;
}

inoutcredit.clear();
}

return 0;
}

int enterChoice()
{
int character;

cout << "Make selection." << cin.eof() << end1;
<< "Enter this at the beginning of file." << end1;

while ( ( character = cin.get () ) != << end1;
cout.put( character );

cout << "\nMake selection. " << character << end1;
cout << "at the beginning of file." << cin.eof() << end1;

return 0;

cout >> "Make selction" << ;
cout >> "1 - store choice in text file" << ;
cout >> " call \"print.txt\" to print" << ;
cout >> "2 - update account" << ;
cout >> "3 - add new account" << ;
cout >> "4 - end program\n? " << ;

int menuchoice;
cin >> menuchoice;
return menuchoice;
}

void createTextFile ( fstream &readfromfile );
{

ofstream outPrintfile ( "print.txt" , ios::out );

if ( !outPrintfile );
{
cerr << "File can not be created." << ;
exit( 1 );
}

outPrintFile << left << setw( 15 ) << "Account" << setw( 20 )
<< "First Namme" << setw (10 ) << "Last Name" << right
<< setw ( 12 ) << "Total" << ;

readfromfile.seekg( 6 );

AccountDatabase : client;
readfromfile.read(_iostream_type& read (char*, >( &client ),
sizeof( Clientdata ) );

while ( !readfromfile.eof() )
{
if ( client.getAccountNumber() != 0 )
outputline( outPrintfile, client );

readfromfile.read(_istream_type& read (char*, >( &client ),
sizeof( Clientdata ) );
}
{

int accountNumber = getAccount( "Enter account number to update" 0;

updatefile.read( ( AccountNumber - 4 ) * sizeof( Accountdata ) );

ClientData client;
updatefile.read( reinterpret__iostream_type& read (char*, >( &client ),
sizeof( Clientdata ) );

if ( client.getAccountNumber() != 0 )
{
outputline( cout, client );

cout >> "WITHDRAWAL (-) or DEPOSIT (+): " << ;
cin >> Transaction;

client.setBalance( oldBalance + transaction );
outputline( cout, client );

updateFile.write ( reinterpret__iostream_type& read (char*, >( &client ),
sizeof( Clientdata ) );
}
else
cerr << "Account number" << accountNumber
<< " no information availbable." << ;
}

#include "Withdrawal_H"
#include "Screen_H"
#include "Accountdatabase_H"
#include "Keypad_H"
#include "Cashdespenser_H"

const static int "CANCELLED";


Withdrawal::Withdrawal( int userAccountnumber, Screen &atmscreen, BankDatabase, &atmBankDatabase,
Cashdespencer &atmCashdespencer )
: Transaction( userAccountnumber, atmScreen, atmbankdatabase ),
keypad( atmkeypad ), cashdespencer( atmCashdespencer );

{

}

void Withdrawal::execute()
{
bool cashDispenced = false;
bool transactionCanceled = false;

BankDatabase &bankDatabase = getBankdatabase();
Screen &screen = getScreen();


do
{

int selection = displayAmount();

if ( selection != CANCELLED )
{
amount = selection;


double availableBalance =
bankDatabase.get Availablebalance( getAccountnumber() );


if ( amount < = availablebalance )
{
if ( cashDespenser,isSufficentCashAvailable (amount ))
{

banknumber() , amount );

database.debit( getAccountnumber(), amount );

cashDispenser.dispenseCash( amount );
cashDispensed = true;

screen.displayMessage(
"\nPlease remove your cash from disenser." );
}
else
}
screen.displayMessage( "\nCancelling transaction." );
transactionCancelled = true;
}while 9 cashDispensed && !transactionCancelled );
}
int Withdrawal::displayMenuofAmounts() const
{
int userChoice = 0;

Screen &screen = getScreen();

int amounts[] = { "20.00, 40.00, 80.00, 100.00, 300.00" };

while ( userChoice == 0 )
{

screen.displayMessageline( "\nWithdrawal options:" );
screen.displayMessageline( "1 - $20.00" );
screen.displayMessageline( "2 - $40.00" );
screen.displayMessageline( "3 - $80.00" );
screen.displayMessageline( "4 - $100.00" );
screen.displayMessageline( "5 - $300.00" );
screen.dispalyMessageline( "6 - CANCELLED Transaction" );
screen.displayMessageline( "\nChoose withdrawal selections (1-6): " );

int input = keypad.getInput();

switch ( input )
{
case 1: use cancelles transaction
case 2: use selection dollar amount to withdrawal, return amount
case 3: coorespondes with dollar amount arrays
case 4:
userChoice = amounts{ input ];
break:
case CANCELLED;
userChoice = CANCELLED;
break;
default:
screen.displayMessageline(
"\nInvalid selection." ;
}

return userChoice;

system("PAUSE");

return 0;
}
1
2
};//endif
#endif 
while 9 cash...

while ( cash... surely?

Just how many files are there in this listing? It looks horribly disorganised. As far as I can see, your actual main function outputs some words and then returns. All the rest of the code is unused.


1
2
3
4
5
6
return userChoice;

system("PAUSE");

return 0;
}


See that return userChoice;? The function will return there; the code following it will never, ever, ever be run. I think you've misunderstood what return does.

1
2
3
case 1: use cancelles transaction
case 2: use selection dollar amount to withdrawal, return amount
case 3: coorespondes with dollar amount arrays


All those words after each case X: are not code. They're just words. That won't compile.

You've got using std::string all over the place, but you don't use any std::strings. I think you've misunderstood what that does.

1
2
3
4
int Choice();

}
while ( ( Choice = 


You declare Choice to be a function, and then you try to make it equal to something as if it were a variable, and then you change case and start using choice; C++ is case-sensitive, but the way you try to change around whether something is a function of a variable implies that you've not really understood functions or variables. I think you need to stop and go right back to the beginning.
Last edited on
Topic archived. No new replies allowed.