Could use some advise please

Hey there, I am messing around while learning to code. I was looking for a great practice program to help me prepare for a exam. Chances are I will already of taken the exam before I get my problem solved, but hey its all good in my book.

so what I am working on is using different functions , switch and Atm_In and Atm_out files. The program I created is like an Atm. When I run my program it works great for my first account, but when I try another account it reads back from the first account, pauses, then reads from the other accounts giving me a 0 balance. Any help would be appreciated.
This is not a completed code, still have a lot to do.

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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
  #include<iostream>
#include<iomanip>
#include<math.h>
#include<fstream>
using namespace std;

// prototype functiions
int option( int account_type);
int checking(double balance_checking, double ending_balance_checking, double const overdraft_fee, double const insufficient_funds, double withdrawl_checking, double deposit_checking);
int savings(double balance_savings, double ending_balance_savings, double const overdraft_fee, double const insufficient_funds, double withdrawl_savings, double deposit_savings);
int holiday(double balance_holiday,  double ending_balance_holiday, double deposit_holiday);


int account_type;
int selection;

double balance_checking, ending_balance_checking, balance_savings, ending_balance_savings, 
balance_holiday, ending_balance_holiday, withdrawl_checking, withdrawl_savings, withdrawl_holiday, deposit_checking, deposit_savings, deposit_holiday;

double const  overdraft_fee = 25.00, insufficient_funds = .05;
ifstream Atm_In;
ofstream Atm_Out;

int main(int argc, const char * argv[])
{
	Atm_In.open("Atm_In.txt"); //open the input file
	Atm_Out.open("Atm_Out.txt");//open the output file
	
	Atm_In >> balance_checking >> balance_savings >> balance_holiday;
	cout << "What would you like to do today?" << endl;
	cout << "( deposit = 11, withdrawl = 22, check your balance = 33 )  ";
	cin >> selection;
	
		option(account_type);
		checking(balance_checking, ending_balance_checking, overdraft_fee, insufficient_funds, withdrawl_checking, deposit_checking);
		savings(balance_savings, ending_balance_savings  ,overdraft_fee, insufficient_funds, withdrawl_savings, deposit_savings);
		holiday(balance_holiday, ending_balance_holiday, deposit_holiday);
}
int option(int account_type)
{
	switch (selection)
	{
	case 11:// deposit
		cout << "Which account would you like to deposit into?"<< endl;
		cout << "( 1 = checking, 2 = savings, 3 = holiday)  ";
		cin >> account_type;
		switch (account_type)
		{
		case 1:// checking
			cout << "You chose to deposit into your checking account." << endl;
			break;
		case 2:// savings 
			cout << "You chose to deposit into your savings account." << endl;
			break;
		case 3://holiday
			cout << "You chose to deposit into your holiday account." << endl;
			break;
		}
		break;
	case 22:// withdrawl
		cout << "Which account would you like to withdrawl from?" << endl;
		cout << "(1 = checking, 2 = savings, 3 = holiday)  ";
		cin >> account_type;
		switch (account_type)
		{
		case 1:// checking 
			cout << "You chose to withdrawl from your checking account."<< endl;
			break;
		case 2://savings
			cout << "You chose to withdrawl from your savings account." << endl;
			break;
		case 3://holiday
			cout << "You chose to withdrawl from your holiday account." << endl;
			break;
		}
		break;
	case 33:// view balance
		cout << "Which account would you like to view balance from?" << endl;
		cout << "(1 = checking, 2 = savings, 3 = holiday, 4 = all)  ";
		cin >> account_type;
		switch (account_type)
		{
		case 1://checking 
			cout << "You chose to view the balance of your checking account." << endl;
			Atm_Out << "Balance Inquiry Checking $" << balance_checking;
			cout << "Available balance Checking $" << balance_checking << endl << endl;
			system("pause"); 
			break;
		case 2:
			cout << "You chose to view the balance of your savings account." << endl;
			Atm_Out << "Blanace Inquiry Savings $" << balance_savings;
			cout << "Available Balance in Savings $" << balance_savings << endl << endl;
			system("pause"); 
			break;
		case 3:
			cout << "You chose to view the balance of your holiday account." << endl;
			Atm_Out << "Balance Inquiry Holiday $" << balance_holiday;
			cout << "Available Balance in Holiday $" << balance_holiday << endl << endl;
			system("pause");
			break;
		case 4:
			cout << "You chose to view all your accounts." << endl;
			Atm_Out << "Balance Inquiry Checking $" << balance_checking << endl << "Blanace Inquiry Savings $" << balance_savings << endl << "Balance Inquiry Holiday $" << balance_holiday;
			cout << "Balance Inquiry Checking $" << balance_checking << endl << "Blanace Inquiry Savings $" << balance_savings << endl << "Balance Inquiry Holiday $" << balance_holiday << endl << endl;
			system("pause");
			break;
		}
		

	}
	
	return 0;

}

int checking(double balance_checking, double ending_balance_checking, double const overdraft_fee, double  const insufficient_funds, double withdrawl_checking, double deposit_checking)
{
	
	
	
		switch (selection)
	{
			Atm_In >> balance_checking;
			
		case 11:  
		case 1:
			cout << "How much would you like to deposit?  ";
			cin >> deposit_checking;
			cout << "You have deposited $" << deposit_checking << " into your checking account" << endl;
			ending_balance_checking = (deposit_checking + balance_checking);
			cout << "Your new ending balance in your checking account is $" << ending_balance_checking << endl << endl;
		
		Atm_Out << ending_balance_checking;
		
		system("pause");
			break;
			
	}
		switch (selection)
		{
			Atm_In >> balance_checking;

		case 22:
		case 1:
			cout << "How much would you like to withdrawl?  ";
			cin >> withdrawl_checking;
			cout << "You have withdrew $" << withdrawl_checking << " from your checking account" << endl;
			ending_balance_checking = (balance_checking - withdrawl_checking);
			cout << "Your new ending balance in your checking account is $" << ending_balance_checking << endl << endl;

			Atm_Out << ending_balance_checking;

			system("pause");
			break;

		}
	
			return 0;
}




int savings(double balance_savings, double ending_balance_savings, double const overdraft_fee, double const insufficient_funds, double withdrawl_savings, double deposit_savings)
{

	switch (selection)
	{
		Atm_In >> balance_savings;

	case 11:
	case 2:
		cout << "How much would you like to deposit?  ";
		cin >> deposit_savings;
		cout << "You have deposited $" << deposit_savings << " into your savings account" << endl;
		ending_balance_checking = (balance_savings + deposit_savings);
		cout << "Your new ending balance in your savings account is $" << ending_balance_savings << endl << endl;

		Atm_Out << ending_balance_savings;

		system("pause");
		
		break;
	}
	switch (selection)
	{
		Atm_In >> balance_savings;

	case 22:
	case 2:
		cout << "How much would you like to withdrawl?  ";
		cin >> withdrawl_savings;
		cout << "You have deposited $" << withdrawl_savings << " into your savings account" << endl;
		ending_balance_checking = (balance_savings - withdrawl_savings);
		cout << "Your new ending balance in your savings account is $" << ending_balance_savings << endl << endl;

		Atm_Out << ending_balance_savings;

		system("pause");

		break;
	}
		return 0;
}

int holiday(double balance_holiday,double ending_balance_holiday, double deposit_holiday)
{
	switch (selection)
	{
		Atm_In >> balance_holiday;

	case 11:
	case 3:
		cout << "How much would you like to deposit?  ";
		cin >> deposit_holiday;
		cout << "You have deposited $" << deposit_holiday << " into your holiday account" << endl;
		ending_balance_checking = (deposit_holiday + balance_holiday);
		cout << "Your new ending balance in your savings account is $" << ending_balance_holiday << endl << endl;

		Atm_Out << ending_balance_holiday;

		system("pause");
		break;
	}
	switch (selection)
	{
		Atm_In >> balance_savings;

	case 22:
	case 3:
		cout << "You can not withdrawl from your holiday savings, it will" << endl;
		cout << "be deposited into your checking account November 1st." << endl;
		

		Atm_Out << ending_balance_savings;

		system("pause");

		break;
	}
	return 1;
}
Topic archived. No new replies allowed.