ATM Machine program not running still!

Pages: 12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//Jesse Livecchi
//ATM Final
//header

#include <string>
using namespace std;

class bankAccount
{
public:
	bankAccount(string);
	string getBankName();
	double getBankBalance();
	void account1();
	void account2();
	void setBankersName(string);
	void withdrawlMoney(double);
	void depositMoney(double);
	void transMoney2(bankAccount &, double);
	void showBankMenu(bankAccount &);
	void manageBankAccounts(bankAccount &, bankAccount &);
	void transMenu(bankAccount &, bankAccount &);
	void transCheck(bankAccount, double &, bool);
	bool getProgStat();
	void displayBalance();
private:
	string accountName;
	double bankBalance;
};


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//main
#include <iostream>
#include <string>
#include "ATMfinal.h"
using namespace std;

int main()
{
	bankAccount checking("Checking Account");
	bankAccount savings("Savings Account");

	do
	{
		manageBankAccounts(checking, savings);
		system("CLS");
		cin.clear();
		cin.ignore(80, '\n');
	}while(getProgStat() == false);
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
//ATM.cpp
#include "ATMfinal.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;

//bool exitProgram = false;
string bankName = "Livecchi National Credit Union";

//initialize
bankAccount::bankAccount(string Name)
{
    bankBalance = 1000;
    setBankersName(Name);
}

//sets account name
void bankAccount::setBankersName(string name)
{
    bankName = name;
}
//get name
string bankAccount::getBankName()
{
    return bankName;
}
//set balance
double bankAccount::getBankBalance()
{
    return bankBalance;
}

void bankAccount::displayBalance()
{
    system("cls");
    cout << "Viewing account balance for account: \"" << getBankName() << "\"" << endl << endl;
    for(int i = 0; i < 100; i++) // menu's block
    cout << "\280" << endl;
    cout << accountName << endl;
    for(int i = 0; i < 40; i++)
    cout << "~";
    cout << endl << fixed << "Bank Account Balance is: $" << setprecision(2) << bankBalance << endl << endl;
    cout << endl;
    system("PAUSE");
}
//transfer $
void bankAccount::transMoney2( bankAccount &bankAccount, double amount)
{
    bankBalance -= amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << endl << endl;
    cout << fixed << setprecision(2) << bankAccount.getBankName() << "Balance: $" << bankAccount.
    getBankBalance() << endl << endl;
    system("PAUSE");
}
void bankAccount::depositMoney(double amount)
{
    bankBalance += amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << bankBalance << endl << endl;
    system("PAUSE");
}
void bankAccount::withdrawlMoney(double amount)
{
    bankBalance -= amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << bankBalance << endl << endl;
    system("PAUSE");
}

void bankAccount::showBankMenu(bankAccount&)
{
    int selected = 0;
    double amount;
    system("CLS");
    cout << "Manage a " << ::bankName << " account: \"" << bankAccount.getBankName() << "\"" << endl << endl;
    for(int i = 0; i < 100; i++)
    cout << "\250";
    cout << endl;
    cout << "1- View Bank Account Balance" << endl;
    cout << "2- Deposit money to this Account" << endl;
    cout << "3- Withdrawl money from this Account" << endl;
    cout << "4- *Return to Main Menu*" << bankName << " Account" << endl;
    cout << "Enter Choice: " << endl;
    cin >> selected;
    switch(selected)
    {
        case 1:
        bankAccount.displayBalance();
        break;
        case 2:
        cout << endl << "Enter deposit amount: $";
        cin >> amount;
        transCheck(bankAccount, amount, false);
        bankAccount.depositMoney(amount);
        break;
        case 3:
        cout << endl << "Enter withdrawl amount: ($" << bankAccount.getBankBalance() << " available): $";
        cin >> amount;
        transCheck(bankAccount, amount, true);
        bankAccount.withdrawlMoney(amount);
        break;
        case 4:
        break;
        default:
        cout << endl << "Invalid Entry please try again" << endl << endl;
        system("PAUSE");
        break;
    }
}

void manageBankAccount(bankAccount &checking, bankAccount &savings)
{
    int selection;
    system("cls");
    cout << "Welcome to " << ::bankName << "." << endl << endl;
    for(int i = 0; i < 100;)
    cout << "\190";
    cout << endl;
    
    cout << "1- Manage " << checking.getBankName() << endl;
    cout << "2- Manage " << savings.getBankName() << endl;
    cout << "3-Transfer Money" << endl;
    cout << "4- Exit " << savings.getBankName() << endl;
    cout << "Enter Selection: ";
    cin >> selection;
    switch(selection)
    {
        case 1:
        showBankMenu(checking);
        break;
        case 2:
        showBankMenu(savings);
        break;
        case 3:
        transMenu(checking, &savings);
        break;
        case 4:
        ::exitProgram = true;
        break;
        default:
        cout << endl << "Invalid entry please try again" << endl << endl;
        system("PAUSE")
        break;
    }
}

void transMenu(bankAccount &account, account2)
{
    int selection;
    double transAmount = 0.00;
    system("CLS");
    cout << "Transfer money between account: " << ::BankName << endl << endl;
    for(int i = 0; i < 80; i++)
    cout << "\190";
    cout << endl;
    
    cout << "1- Transfer from \"" << account1.getBankName() << "to" << account2.getBankName() << "\"" << endl;
    
    cout << "2- Transfer from \"" << account2.getBankName() << "to" << account1.getBankName() << "\"" << endl;
    
    cout << "Back to Main Menu" << endl;
    
    cout << endl << "Enter Selection: ";
    cin >> selection;
    switch(selection)
    {
        case 1:
        cout << endl << "Enter amount of transfer ($" << account1.getBankBalance() << " available): $";
        cin >> transAmount;
        transCheck(account1, transAmount, true);
        
        account1.transMoney2(account2, transAmount);
        break;
        case 2:
        cout << endl << "Enter amount of transfer ($" << account2.getBankBalance() << " available): $";
        cin >> transAmount;
        transCheck(account2, transAmount, true);
        
        account2.transMoney2(account1, transAmount);
        break;
        case 3:
        break;
        default:
        cout << endl << "Invalid entry please try again" << endl << endl;
        system("PAUSE")
        break;
    }
}
void transCheck(/*bankAccount, double &amount, bool checkOverdrawl*/)
{
    if(fmod((amount * 100), 1) != 0.00)
    {
        cout << endl << "This entry is invalid. Cancelling..." << endl;
        amount = 0;
    }
    
    else if(amount < 0)
    {
        cout << endl << "Cannot transfer a Negative amount." << endl;
        amount = 0;
    }
    else
    {
        cout << endl << " Transaction Processing " << endl;
    }
}
bool getProgStat()
{
    return exitProgram;
}

so the project is to make an atm that can use 2 accounts and transfer money within those accounts withdrawl and deposit money as well.
I am a new programmer who does not know what im doing but really need to make this work or i wont pass the class...
please help me my error will be below this part thanks a lot!
the error report i get back im not sure what any of this means i know its all similar but i have had my book stolen and simply havent been able to figure it out on my own with help in another post and within google searches and such it is probably an easy fix but i havent gotten to it yet!

1>------ Build started: Project: ATM, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\users\jesse\desktop\c++\atm\atm\main.cpp(13): error C3861: 'manageBankAccounts': identifier not found
1>c:\users\jesse\desktop\c++\atm\atm\main.cpp(17): error C3861: 'getProgStat': identifier not found
1>  ATMfinal.cpp
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(74): warning C4832: token '.' is illegal after UDT 'bankAccount'
1>          c:\users\jesse\desktop\c++\atm\atm\atmfinal.h(8) : see declaration of 'bankAccount'
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(74): error C2275: 'bankAccount' : illegal use of this type as an expression
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(74): error C2228: left of '.getBankName' must have class/struct/union
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(87): error C2143: syntax error : missing ';' before '.'
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(87): error C2143: syntax error : missing ';' before '.'
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(92): error C2275: 'bankAccount' : illegal use of this type as an expression
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(93): error C2143: syntax error : missing ';' before '.'
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(93): error C2143: syntax error : missing ';' before '.'
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(96): warning C4832: token '.' is illegal after UDT 'bankAccount'
1>          c:\users\jesse\desktop\c++\atm\atm\atmfinal.h(8) : see declaration of 'bankAccount'
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(96): error C2275: 'bankAccount' : illegal use of this type as an expression
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(96): error C2228: left of '.getBankBalance' must have class/struct/union
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(98): error C2275: 'bankAccount' : illegal use of this type as an expression
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(99): error C2143: syntax error : missing ';' before '.'
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(99): error C2143: syntax error : missing ';' before '.'
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(128): error C3861: 'showBankMenu': identifier not found
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(131): error C3861: 'showBankMenu': identifier not found
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(134): error C3861: 'transMenu': identifier not found
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(137): error C2039: 'exitProgram' : is not a member of '`global namespace''
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(137): error C2065: 'exitProgram' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(142): error C2143: syntax error : missing ';' before 'break'
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(146): error C2061: syntax error : identifier 'account2'
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(151): error C2039: 'BankName' : is not a member of '`global namespace''
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(151): error C2065: 'BankName' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(156): error C2065: 'account1' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(156): error C2228: left of '.getBankName' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(156): error C2065: 'account2' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(156): error C2228: left of '.getBankName' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(158): error C2065: 'account2' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(158): error C2228: left of '.getBankName' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(158): error C2065: 'account1' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(158): error C2228: left of '.getBankName' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(167): error C2065: 'account1' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(167): error C2228: left of '.getBankBalance' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(169): error C2065: 'account1' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(169): error C3861: 'transCheck': identifier not found
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(171): error C2065: 'account1' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(171): error C2228: left of '.transMoney2' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(171): error C2065: 'account2' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(174): error C2065: 'account2' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(174): error C2228: left of '.getBankBalance' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(176): error C2065: 'account2' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(176): error C3861: 'transCheck': identifier not found
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(178): error C2065: 'account2' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(178): error C2228: left of '.transMoney2' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(178): error C2065: 'account1' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(185): error C2143: syntax error : missing ';' before 'break'
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(190): error C2065: 'amount' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(193): error C2065: 'amount' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(196): error C2065: 'amount' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(199): error C2065: 'amount' : undeclared identifier
1>c:\users\jesse\desktop\c++\atm\atm\atmfinal.cpp(208): error C2065: 'exitProgram' : undeclared identifier
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I suspect that you meant the following functions in the 'bankAccount' class to be static:

1
2
3
4
void showBankMenu(bankAccount &);
void manageBankAccounts(bankAccount &, bankAccount &);
void transMenu(bankAccount &, bankAccount &);
void transCheck(bankAccount&, double &, bool);


having said that it is still within the class so the source code for the function needs to be declared as within the class. You also had a few functions with different arguments in the source code compared to how they were proto-typed in the header. Plus you had forgotten a few semi-colons at the end of lines.

You have not yet to declared the 'exitProgram()' function in the 'bankAccount' class, quite what this is meant to do I don't know so will leave you to write this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <string>
using namespace std;

class bankAccount
{
public:
	bankAccount(string);
	string getBankName();
	double getBankBalance();
	void account1();
	void account2();
	void setBankersName(string);
	void withdrawlMoney(double);
	void depositMoney(double);
	void transMoney2(bankAccount &, double);
	static void showBankMenu(bankAccount &);
	static void manageBankAccounts(bankAccount &, bankAccount &);
	static void transMenu(bankAccount &, bankAccount &);
	static void transCheck(bankAccount&, double &, bool);
	static bool getProgStat();
	void displayBalance();
private:
	string accountName;
	double bankBalance;
};


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
//ATM.cpp
#include "ATMfinal.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;

//bool exitProgram = false;
string bankName = "Livecchi National Credit Union";

//initialize
bankAccount::bankAccount(string Name)
{
    bankBalance = 1000;
    setBankersName(Name);
}

//sets account name
void bankAccount::setBankersName(string name)
{
    bankName = name;
}
//get name
string bankAccount::getBankName()
{
    return bankName;
}
//set balance
double bankAccount::getBankBalance()
{
    return bankBalance;
}

void bankAccount::displayBalance()
{
    system("cls");
    cout << "Viewing account balance for account: \"" << getBankName() << "\"" << endl << endl;
    for(int i = 0; i < 100; i++) // menu's block
    cout << "\280" << endl;
    cout << accountName << endl;
    for(int i = 0; i < 40; i++)
    cout << "~";
    cout << endl << fixed << "Bank Account Balance is: $" << setprecision(2) << bankBalance << endl << endl;
    cout << endl;
    system("PAUSE");
}
//transfer $
void bankAccount::transMoney2( bankAccount &bankAccount, double amount)
{
    bankBalance -= amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << endl << endl;
    cout << fixed << setprecision(2) << bankAccount.getBankName() << "Balance: $" << bankAccount.
    getBankBalance() << endl << endl;
    system("PAUSE");
}
void bankAccount::depositMoney(double amount)
{
    bankBalance += amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << bankBalance << endl << endl;
    system("PAUSE");
}
void bankAccount::withdrawlMoney(double amount)
{
    bankBalance -= amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << bankBalance << endl << endl;
    system("PAUSE");
}

void bankAccount::showBankMenu(bankAccount& bankAccount)
{
    int selected = 0;
    double amount;
    system("CLS");
    cout << "Manage a " << ::bankName << " account: \"" << bankAccount.getBankName() << "\"" << endl << endl;
    for(int i = 0; i < 100; i++)
    cout << "\250";
    cout << endl;
    cout << "1- View Bank Account Balance" << endl;
    cout << "2- Deposit money to this Account" << endl;
    cout << "3- Withdrawl money from this Account" << endl;
    cout << "4- *Return to Main Menu*" << bankName << " Account" << endl;
    cout << "Enter Choice: " << endl;
    cin >> selected;
    switch(selected)
    {
        case 1:
        bankAccount.displayBalance();
        break;
        case 2:
        cout << endl << "Enter deposit amount: $";
        cin >> amount;
        transCheck(bankAccount, amount, false);
        bankAccount.depositMoney(amount);
        break;
        case 3:
        cout << endl << "Enter withdrawl amount: ($" << bankAccount.getBankBalance() << " available): $";
        cin >> amount;
        transCheck(bankAccount, amount, true);
        bankAccount.withdrawlMoney(amount);
        break;
        case 4:
        break;
        default:
        cout << endl << "Invalid Entry please try again" << endl << endl;
        system("PAUSE");
        break;
    }
}

void bankAccount::manageBankAccounts(bankAccount &checking, bankAccount &savings)
{
    int selection;
    system("cls");
    cout << "Welcome to " << ::bankName << "." << endl << endl;
    for(int i = 0; i < 100;)
    cout << "\190";
    cout << endl;
    
    cout << "1- Manage " << checking.getBankName() << endl;
    cout << "2- Manage " << savings.getBankName() << endl;
    cout << "3-Transfer Money" << endl;
    cout << "4- Exit " << savings.getBankName() << endl;
    cout << "Enter Selection: ";
    cin >> selection;
    switch(selection)
    {
        case 1:
        showBankMenu(checking);
        break;
        case 2:
        showBankMenu(savings);
        break;
        case 3:
        transMenu(checking, savings);
        break;
        case 4:
        ::exitProgram = true;
        break;
        default:
        cout << endl << "Invalid entry please try again" << endl << endl;
        system("PAUSE");
        break;
    }
}

void bankAccount::transMenu(bankAccount &account1, bankAccount& account2)
{
    int selection;
    double transAmount = 0.00;
    system("CLS");
    cout << "Transfer money between account: " << account1.getBankName() << endl << endl;
    for(int i = 0; i < 80; i++)
    cout << "\190";
    cout << endl;
    
    cout << "1- Transfer from \"" << account1.getBankName() << "to" << account2.getBankName() << "\"" << endl;
    
    cout << "2- Transfer from \"" << account2.getBankName() << "to" << account1.getBankName() << "\"" << endl;
    
    cout << "Back to Main Menu" << endl;
    
    cout << endl << "Enter Selection: ";
    cin >> selection;
    switch(selection)
    {
        case 1:
        cout << endl << "Enter amount of transfer ($" << account1.getBankBalance() << " available): $";
        cin >> transAmount;
        transCheck(account1, transAmount, true);
        
        account1.transMoney2(account2, transAmount);
        break;
        case 2:
        cout << endl << "Enter amount of transfer ($" << account2.getBankBalance() << " available): $";
        cin >> transAmount;
        transCheck(account2, transAmount, true);
        
        account2.transMoney2(account1, transAmount);
        break;
        case 3:
        break;
        default:
        cout << endl << "Invalid entry please try again" << endl << endl;
        system("PAUSE");
        break;
    }
}
void bankAccount::transCheck(bankAccount& acct, double &amount, bool checkOverdrawl)
{
    if(fmod((amount * 100), 1) != 0.00)
    {
        cout << endl << "This entry is invalid. Cancelling..." << endl;
        amount = 0;
    }
    
    else if(amount < 0)
    {
        cout << endl << "Cannot transfer a Negative amount." << endl;
        amount = 0;
    }
    else
    {
        cout << endl << " Transaction Processing " << endl;
    }
}

bool bankAccount::getProgStat()
{
    return exitProgram;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//main
#include <iostream>
#include <string>
#include "ATMfinal.h"
using namespace std;

int main()
{
	bankAccount checking("Checking Account");
	bankAccount savings("Savings Account");

	do
	{
		bankAccount::manageBankAccounts(checking, savings);
		system("CLS");
		cin.clear();
		cin.ignore(80, '\n');
	}while(bankAccount::getProgStat() == false);
}


HTH
Last edited on
Starting with your first two errors:

In your header file, you've declared manageBankAccounts and getProgStat as methods of the bankAccount class. But at line 111 you define manageBankAccounts as a global function, and in main, you call them both as if they were global functions.

What are they supposed to be? Methods of the class, or global functions?
im not really sure where i was going with that but with the new code posted above i believe i am still getting the error you (mikeyboy) are taking about and im not sure why...

1>------ Build started: Project: ATMfix, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\users\jesse\desktop\c++\atmfix\atmfix\main.cpp(18): error C3861: 'getProgStat': identifier not found
1>  ATM.cpp
1>c:\users\jesse\desktop\c++\atmfix\atmfix\atm.cpp(129): error C3861: 'showBankMenu': identifier not found
1>c:\users\jesse\desktop\c++\atmfix\atmfix\atm.cpp(132): error C3861: 'showBankMenu': identifier not found
1>c:\users\jesse\desktop\c++\atmfix\atmfix\atm.cpp(135): error C3861: 'transMenu': identifier not found
1>c:\users\jesse\desktop\c++\atmfix\atmfix\atm.cpp(138): error C2039: 'exitProgram' : is not a member of '`global namespace''
1>c:\users\jesse\desktop\c++\atmfix\atmfix\atm.cpp(138): error C2065: 'exitProgram' : undeclared identifier
1>c:\users\jesse\desktop\c++\atmfix\atmfix\atm.cpp(138): warning C4805: '==' : unsafe mix of type ''unknown-type'' and type 'bool' in operation
1>c:\users\jesse\desktop\c++\atmfix\atmfix\atm.cpp(210): error C2065: 'exitProgram' : undeclared identifier
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Well did you try the correct code I posted earlier?
yes i did and something was wrong so i tried fixing a few things along with the post below you. this is my code at the moment

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
//ATM.cpp
#include "ATMfinal.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;

//bool exitProgram = false;
string bankName = "Livecchi National Credit Union";

//initialize
bankAccount::bankAccount(string Name)
{
    bankBalance = 1000;
    setBankersName(Name);
}

//sets account name
void bankAccount::setBankersName(string name)
{
    bankName = name;
}
//get name
string bankAccount::getBankName()
{
    return bankName;
}
//set balance
double bankAccount::getBankBalance()
{
    return bankBalance;
}

void bankAccount::displayBalance()
{
    system("cls");
    cout << "Viewing account balance for account: \"" << getBankName() << "\"" << endl << endl;
    for(int i = 0; i < 100; i++) // menu's block
    cout << "\280" << endl;
    cout << accountName << endl;
    for(int i = 0; i < 40; i++)
    cout << "~";
    cout << endl << fixed << "Bank Account Balance is: $" << setprecision(2) << bankBalance << endl << endl;
    cout << endl;
    system("PAUSE");
}
//transfer $
void bankAccount::transMoney2( bankAccount &bankAccount, double amount)
{
    bankBalance -= amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << endl << endl;
    cout << fixed << setprecision(2) << bankAccount.getBankName() << "Balance: $" << bankAccount.
    getBankBalance() << endl << endl;
    system("PAUSE");
}
void bankAccount::depositMoney(double amount)
{
    bankBalance += amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << bankBalance << endl << endl;
    system("PAUSE");
}
void bankAccount::withdrawlMoney(double amount)
{
    bankBalance -= amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << bankBalance << endl << endl;
    system("PAUSE");
}

void bankAccount::showBankMenu(bankAccount& bankAccount)
{
    int selected = 0;
    double amount;
    system("CLS");
    cout << "Manage a " << ::bankName << " account: \"" << bankAccount.getBankName() << "\"" << endl << endl;
    for(int i = 0; i < 100; i++)
    cout << "\250";
    cout << endl;
    cout << "1- View Bank Account Balance" << endl;
    cout << "2- Deposit money to this Account" << endl;
    cout << "3- Withdrawl money from this Account" << endl;
    cout << "4- *Return to Main Menu*" << bankName << " Account" << endl;
    cout << "Enter Choice: " << endl;
    cin >> selected;
    switch(selected)
    {
        case 1:
        bankAccount.displayBalance();
        break;
        case 2:
        cout << endl << "Enter deposit amount: $";
        cin >> amount;
        transCheck(bankAccount, amount, false);
        bankAccount.depositMoney(amount);
        break;
        case 3:
        cout << endl << "Enter withdrawl amount: ($" << bankAccount.getBankBalance() << " available): $";
        cin >> amount;
        transCheck(bankAccount, amount, true);
        bankAccount.withdrawlMoney(amount);
        break;
        case 4:
        break;
        default:
        cout << endl << "Invalid Entry please try again" << endl << endl;
        system("PAUSE");
        break;
    }
}

void manageBankAccounts(bankAccount &checking, bankAccount &savings)
{
    int selection;
    system("cls");
    cout << "Welcome to " << ::bankName << "." << endl << endl;
    for(int i = 0; i < 100;)
    cout << "\190";
    cout << endl;
    
    cout << "1- Manage " << checking.getBankName() << endl;
    cout << "2- Manage " << savings.getBankName() << endl;
    cout << "3-Transfer Money" << endl;
    cout << "4- Exit " << savings.getBankName() << endl;
    cout << "Enter Selection: ";
    cin >> selection;
    switch(selection)
    {
        case 1:
			showBankMenu(savings);
			break;
			
        case 2:
			showBankMenu(checking);
			break;
        case 3:
			transMenu(checking, savings);
			break;
        case 4:
			::exitProgram == true;
			break;
        default:
        cout << endl << "Invalid entry please try again" << endl << endl;
        system("PAUSE");
        break;
    }
}

void bankAccount::transMenu(bankAccount &account1, bankAccount& account2)
{
    int selection;
    double transAmount = 0.00;
    system("CLS");
    cout << "Transfer money between account: " << account1.getBankName() << endl << endl;
    for(int i = 0; i < 80; i++)
    cout << "\190";
    cout << endl;
    
    cout << "1- Transfer from \"" << account1.getBankName() << "to" << account2.getBankName() << "\"" << endl;
    
    cout << "2- Transfer from \"" << account2.getBankName() << "to" << account1.getBankName() << "\"" << endl;
    
    cout << "Back to Main Menu" << endl;
    
    cout << endl << "Enter Selection: ";
    cin >> selection;
    switch(selection)
    {
        case 1:
        cout << endl << "Enter amount of transfer ($" << account1.getBankBalance() << " available): $";
        cin >> transAmount;
        transCheck(account1, transAmount, true);
        
        account1.transMoney2(account2, transAmount);
        break;
        case 2:
        cout << endl << "Enter amount of transfer ($" << account2.getBankBalance() << " available): $";
        cin >> transAmount;
        transCheck(account2, transAmount, true);
        
        account2.transMoney2(account1, transAmount);
        break;
        case 3:
        break;
        default:
        cout << endl << "Invalid entry please try again" << endl << endl;
        system("PAUSE");
        break;
    }
}
void bankAccount::transCheck(bankAccount& acct, double &amount, bool checkOverdrawl)
{
    if(fmod((amount * 100), 1) != 0.00)
    {
        cout << endl << "This entry is invalid. Cancelling..." << endl;
        amount = 0;
    }
    
    else if(amount < 0)
    {
        cout << endl << "Cannot transfer a Negative amount." << endl;
        amount = 0;
    }
    else
    {
        cout << endl << " Transaction Processing " << endl;
    }
}

bool bankAccount::getProgStat()
{
    return exitProgram;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//main
#include <iostream>
#include <string>
#include "ATMfinal.h"
using namespace std;

int main()
{
	bankAccount checking("Checking Account");
	bankAccount savings("Savings Account");

	do
	{
		bankAccount::manageBankAccounts(checking, savings);
		system("CLS");
		cin.clear();
		cin.ignore(80, '\n');
	}while(getProgStat() == false);
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <string>
using namespace std;

class bankAccount
{
public:
	bankAccount(string);
	string getBankName();
	double getBankBalance();
	void account1();
	void account2();
	void setBankersName(string);
	void withdrawlMoney(double);
	void depositMoney(double);
	void transMoney2(bankAccount &, double);
	static void showBankMenu(bankAccount &);
	static void manageBankAccounts(bankAccount &, bankAccount &);
	static void transMenu(bankAccount &, bankAccount &);
	static void transCheck(bankAccount&, double &, bool);
	static bool getProgStat();
	void displayBalance();
private:
	string accountName;
	double bankBalance;
};
If i am not able the exit the program then my program would count as being not finished which is bad...
At line 111, you're still defining manageBankAccounts as a standalone function, not as a method of the bankAccount class.

ajh32 fixed that for you in the code s/he posted, so why did you not use that fix?

Edit: You've also ignored the fix you were given for your call to getProgStat() in main.
Last edited on
i did use it but the ::exitProgram part "
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
void bankAccount::manageBankAccounts(bankAccount &checking, bankAccount &savings)
{
    int selection;
    system("cls");
    cout << "Welcome to " << ::bankName << "." << endl << endl;
    for(int i = 0; i < 100;)
    cout << "\190";
    cout << endl;
    
    cout << "1- Manage " << checking.getBankName() << endl;
    cout << "2- Manage " << savings.getBankName() << endl;
    cout << "3-Transfer Money" << endl;
    cout << "4- Exit " << savings.getBankName() << endl;
    cout << "Enter Selection: ";
    cin >> selection;
    switch(selection)
    {
        case 1:
        showBankMenu(checking);
        break;
        case 2:
        showBankMenu(savings);
        break;
        case 3:
        transMenu(checking, savings);
        break;
        case 4:
        ::exitProgram = true;
        break;
        default:
        cout << endl << "Invalid entry please try again" << endl << endl;
        system("PAUSE");
        break;
    }
}
"
still isnt working and i need this to work
You'd find this a lot easier if you actually read what people are writing. ajh32 wrote:

You have not yet to declared the 'exitProgram()' function in the 'bankAccount' class, quite what this is meant to do I don't know so will leave you to write this.
I said in my original post enclosing the updated code, that I hadn't written the ::exitProgram() function as I didn't understand what you were trying to do with that. It's bad practice to exit a program in the middle. You would be best advised to have a program loop in main() and to only exit when a certain condition arises like the user has chosen the endProgram option in the menu. I would suggest that you replace the exitProgram in the various places and return back out of that function.

So, you shouldn't get any errors apart from those referring to the 'exitProgram' function that currently doesn't exist?

BTW - I'm male.
Last edited on


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//ATM.cpp
#include "ATMfinal.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;

//bool exitProgram = false;
string bankName = "Livecchi National Credit Union";
bool exitProgram = false;

//initialize
bankAccount::bankAccount(string Name)
{
    bankBalance = 1000;
    setBankersName(Name);
}

//sets account name
void bankAccount::setBankersName(string name)
{
    bankName = name;
}
//get name
string bankAccount::getBankName()
{
    return bankName;
}
//set balance
double bankAccount::getBankBalance()
{
    return bankBalance;
}

void bankAccount::displayBalance()
{
    system("cls");
    cout << "Viewing account balance for account: \"" << getBankName() << "\"" << endl << endl;
    cout << endl << accountName << endl;
    for(int i = 0; i < 40; i++)
    cout << "~";
    cout << endl << fixed << "Bank Account Balance is: $" << setprecision(2) << bankBalance << endl << endl;
    cout << endl;
    system("PAUSE");
}
//transfer $
void bankAccount::transMoney2( bankAccount &bankAccount, double amount)
{
    bankBalance -= amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << endl << endl;
    cout << fixed << setprecision(2) << bankAccount.getBankName() << "Balance: $" << bankAccount.
    getBankBalance() << endl << endl;
    system("PAUSE");
}
void bankAccount::depositMoney(double amount)
{
    bankBalance += amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << bankBalance << endl << endl;
    system("PAUSE");
}
void bankAccount::withdrawlMoney(double amount)
{
    bankBalance -= amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << bankBalance << endl << endl;
    system("PAUSE");
}

void showBankMenu(bankAccount &account)
{
    int selected = 0;
    double amount;
    system("CLS");
    cout << "Manage a " << ::bankName << " account: \"" << account.getBankName() << "\"" << endl << endl;
    cout << endl;
    cout << "1- View Bank Account Balance" << endl;
    cout << "2- Deposit money to this Account" << endl;
    cout << "3- Withdrawl money from this Account" << endl;
    cout << "4- *Return to Main Menu*" << bankName << " Account" << endl;
    cout << "Enter Choice: " << endl;
    cin >> selected;
    switch(selected)
    {
        case 1:
        account.displayBalance();
        break;
        case 2:
        cout << endl << "Enter deposit amount: $";
        cin >> amount;
        transCheck(account, amount, false);
        account.depositMoney(amount);
        break;
        case 3:
        cout << endl << "Enter withdrawl amount: ($" << account.getBankBalance() << " available): $";
        cin >> amount;
        transCheck(account, amount, true);
        account.withdrawlMoney(amount);
        break;
        case 4:
        break;
        default:
        cout << endl << "Invalid Entry please try again" << endl << endl;
        system("PAUSE");
        break;
    }
}

void manageBankAccounts(bankAccount &checking, bankAccount &savings)
{
    int selection = 0;
    system("cls");
    cout << "Welcome to " << ::bankName << "." << endl << endl;
	cout << endl;
    cout << "1- Manage " << checking.getBankName() << endl;
    cout << "2- Manage " << savings.getBankName() << endl;
    cout << "3-Transfer Money" << endl;
    cout << "4- Exit " << savings.getBankName() << endl;
    cout << "Enter Selection: ";
    cin >> selection;
    switch(selection)
    {
        case 1:
			showBankMenu(checking);
			break;
        case 2:
			showBankMenu(savings);
			break;
        case 3:
			transMenu(checking, savings);
			break;
        case 4:
			::exitProgram = true;
			break;
        default:
			cout << endl << "Invalid entry please try again" << endl << endl;
			system("PAUSE");
			break;
    }
}

void transMenu(bankAccount &account1, bankAccount& account2)
{
    int selection;
    double transAmount = 0.00;
    system("CLS");
    cout << "Transfer money between account: " << account1.getBankName() << endl << endl;
    cout << endl;
    
    cout << "1- Transfer from \"" << account1.getBankName() << " to " << account2.getBankName() << "\"" << endl;
    
    cout << "2- Transfer from \"" << account2.getBankName() << " to " << account1.getBankName() << "\"" << endl;
    
    cout << "3- Back to Main Menu" << endl;
    
    cout << endl << "Enter Selection: ";
    cin >> selection;
    switch(selection)
    {
        case 1:
			cout << endl << "Enter amount of transfer ($" << account1.getBankBalance() << " available): $";
			cin >> transAmount;
			transCheck(account1, transAmount, true);
			account1.transMoney2(account2, transAmount);
			break;
        case 2:
			cout << endl << "Enter amount of transfer ($" << account2.getBankBalance() << " available): $";
			cin >> transAmount;
			transCheck(account2, transAmount, true);
			account2.transMoney2(account1, transAmount);
			break;
        case 3:
			break;
        default:
			cout << endl << "Invalid entry please try again" << endl << endl;
			system("PAUSE");
			break;
    }
}
void transCheck(bankAccount& acct, double &amount, bool checkOverdrawl)
{
    if(fmod((amount * 100), 1) != 0.00)
    {
        cout << endl << "This entry is invalid. Cancelling..." << endl;
        amount = 0;
    }
    
    else if(amount < 0)
    {
        cout << endl << "Cannot transfer a Negative amount." << endl;
        amount = 0;
    }
    else
    {
        cout << endl << " Transaction Processing " << endl;
    }
}

bool getProgStat()
{
    return ::exitProgram;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//main
#include <iostream>
#include <string>
#include "ATMfinal.h"
using namespace std;

int main()
{
	bankAccount checking("Checking Account");
	bankAccount savings("Savings Account");

	do
	{
		manageBankAccounts(checking, savings);
		system("CLS");
		cin.clear();
		cin.ignore(80, '\n');
	}while(getProgStat() == false);
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

#include <string>
using namespace std;

class bankAccount
{
public:
	bankAccount(string);
	string getBankName();
	double getBankBalance();
	void account1();
	void account2();
	void setBankersName(string);
	void withdrawlMoney(double);
	void depositMoney(double);
	void transMoney2(bankAccount &, double);
	void displayBalance();
private:
	string accountName;
	double bankBalance;
};

void showBankMenu(bankAccount &);
void manageBankAccounts(bankAccount &, bankAccount &);
void transMenu(bankAccount &, bankAccount &);
void transCheck(bankAccount&, double &, bool);
bool getProgStat();
so a couple of friend helped me figure out how to make it run...but it only runs with the savings account and im unsure why it also only transfers the money and doesnt display the amount of money left...i dont know how to make that work

here is my coding
i really need to get this to work correctly or im going to fail the class... please i dont know what is wrong now have tried everything i know of to fix it and none of it does anything
Can you be a bit more specific about what's wrong? What inputs are you entering to the menus? What behaviour are you seeing? How does that behaviour differ from the expected behaviour?
Well using the following bankAccount function:

 
void bankAccount::transMoney2( bankAccount &bankAccount, double amount)


You're reducing the current bankAccount with the value of argv[1] but you're not doing what the function name implies i.e. transferring the amount to the bankAccount at argv[0]. It would be better if you directly took the 'amount' from the argv[0] (BTW be better if it had a name that was different from its class name, i.e. 'account') and deposited it in the current bankAccount instance i.e. the instance we're 'inside' aka 'this'.
ATMfinal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <string>
using namespace std;

class bankAccount
{
public:
	bankAccount(string);
	string getBankName();
	double getBankBalance();
	void account1();
	void account2();
	void setBankersName(string);
	double withdrawlMoney(double);
	double depositMoney(double);
	void transMoney2(bankAccount &, double);
	void displayBalance();
private:
	string accountName;
	double bankBalance;
};

void showBankMenu(bankAccount &);
void manageBankAccounts(bankAccount &, bankAccount &);
void transMenu(bankAccount &, bankAccount &);
void transCheck(bankAccount&, double &, bool);
bool getProgStat();


ATM.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
...
//transfer $
void bankAccount::transMoney2( bankAccount &bankAccount, double amount)
{
    depositMoney(bankAccount.withdrawlMoney(amount));
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << endl << endl;
    cout << fixed << setprecision(2) << bankAccount.getBankName() << "Balance: $" << bankAccount.
    getBankBalance() << endl << endl;
    system("PAUSE");
}

double bankAccount::depositMoney(double amount)
{
    bankBalance += amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << bankBalance << endl << endl;
//    system("PAUSE");
    return amount;
}

double bankAccount::withdrawlMoney(double amount)
{
    bankBalance -= amount;
    cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << bankBalance << endl << endl;
//    system("PAUSE");
    return amount;
}
...
Last edited on
Thank you everyone so much it perfect now! have a nice holiday!
Pages: 12