The program lets the user be the customer, banker, or supervisor, and all of their privileges involve structs. I made an array of 100 structs for 100 potential customers, and I need to do something similar for banking.
I'm trying to put customer and banker's info detailed in that struct into a list on a text file that opens at the program startup, reads from it, writes to it, etc...otherwise users need to remake their account EVERY time they use the program
I need help finishing that part, and any additional stuff would be fan-TAST-ic...
1.#include <iostream>
2.#include <fstream>
3.
4.using namespace std;
5.//include protype functions
6.enum AccountType
7.{unknown = -1, Checking, Savings, CreditCard, InstantAccess};
8.
9.struct customerInfo
10. {
11. char firstName[20];
12. char lastName[20];
13. float amount;
14. AccountType type;
15. };
16.
17.int main()
18.{
19. char choice;
20. bool terminate = false;
21. int i = 0;
22. const int SIZE = 100;
23. @@ifstream inFile;
24. @@ofstream outFile;
25.
26. customerInfo myAccount[SIZE];
27.
28. //float depositAmount (){};
29. //float withdrawAmount (){};
30. //inFile.open("
31.
32. while (!terminate)
33. {
34. cout << "WELCOME TO SO-AND-SO BANK!\n\n" << "Please enter an option, are you a:\n\n"
35. << "A)Customer\n"
36. << "B)Bank Employee\n"
37. << "C)Bank Supervisor\n"
38. << "D)Quit the application\n\n";
39. cin >> choice;
40.
41. switch(choice)
42. {
43. case 'a':
44. case 'A':
45. cout << "Welcome to So-and-So Bank Customer Services!\n" << "Please enter an option:\n\n";
46. //Customer options
47. cout << "A)Functions: Balance Inquiry\n"
48. << "B)Deposit Funds\n"
49. << "C)Withdraw funds\n"
50. << "D)Transfer Funds to another account (like from Checking to Savings or to Credit Card)\n"
51. << "E)Anything else that you want to add\n"
52. << "F)Quit the application\n\n";
53. cin >> choice;
54.
55. switch(choice)
56. {
57. case 'a':
58. case 'A':
59. //struct name, amount, type
60. @@//file.open("so_and_so_bank.txt", ios::in|ios::out)
61. for(i = 0; i < SIZE; i++) //edit
62. {
63. cout << "Enter your first name (20 characters or less):\n\n";
64. cin >> myAccount[i].firstName;
65. cout << "Enter your last name (20 characters or less):\n\n";
66. cin >> myAccount[i].lastName;
67.
68. loop:
69. cout << "What type of account do you wish to view?\n\n"
70. << "1. Checking\n" << "2. Savings\n" << "3. CreditCard\n"
71. << "4. InstantAccess\n" << "5. Quit";
72. cin >> choice; //consider
73. {
74. if(choice == '1')
75. {
76. myAccount[i].type = Checking;
77. }
78. if(choice == '2')
79. {
80. myAccount[i].type = Savings;
81. }
82. if(choice == '3')
83. {
84. myAccount[i].type = CreditCard;
85. }
86. if(choice == '4')
87. {
88. myAccount[i].type = InstantAccess;
89. }
90. if(choice == '5')
91. {
92. cout << "You have chosen to quit, we appreciate your business.";
93. terminate = true;
94. }
95. else
96. {
97. cout << "You've entered an invalid option, please try again";
98. goto loop;
99. }
100. }
101.
102. //include breakable
103. cout << "Your account balance is: " << myAccount[i].amount;
104. //
105. };
106.
107. break;
108. case 'b':
109. case 'B':
110. //depositAmount();
111. break;
112. case 'c':
113. case 'C':
114. //withdrawAmount();
115. break;
116. case 'd':
117. case 'D':
118. //transfer enum
119. break;
120. case 'e':
121. case 'E':
122. //while or goto loop
123. break;
124. case 'f':
125. case 'F':
126. cout << "You have chosen to quit, we appreciate your business.";
127. terminate = true;
128. break;
129. default:
130. cout << "You have entered an invalid option, please try again.\n\n";
131. break;
132. }
133. break;
134.
135. case 'b':
136. case 'B':
137. cout << "Welcome to So-and-So Bank Employee Services!\n" << "Please enter an option:\n\n";
138. //Cascading customer data
139. //a.Everything in the Customer Interface, plus
140. cout << "A)Interface to ADD a new Customer to the Bank\n"
141. << "B)Interface to DELETE a Customer from the Bank\n"
142. << "C)Search for a Record based on a “Name of a Customer” (using simple Sequential Search)\n"
143. << "D)Quit the application\n\n";
144. cin >> choice;
145.
146. switch(choice)
147. {
148. case 'a':
149. case 'A':
150. //struct new customer
151. @@for(i = 0; i < SIZE; i++) //edit
152. {
153. cout << "Enter your first name (20 characters or less):\n\n";
154. cin >> myAccount[i].firstName;
155. cout << "Enter your last name (20 characters or less):\n\n";
156. cin >> myAccount[i].lastName;
157. };
158. break;
159. case 'b':
160. case 'B':
161. //struct delete customer (Case C w/ remove name)
162. break;
163. case 'c':
164. case 'C':
165. //for loop name search, cin i, i customer
166. cout << "So-and-So Bank Customers:\n";
167. for(i = 0; i < SIZE; i++)
168. {
169. cout << i << ". " << myAccount[i].lastName << ", " << myAccount[i].firstName << "\n";
170. };
171. cout << "Select customer number:\n\n";
172. cin >> i;
173.
174. //cout << myAccount[i].amount;
175.
176. break;
177. case 'd':
178. case 'D':
179. cout << "You have chosen to quit, we appreciate your business.";
180. terminate = true;
181. break;
182. default:
183. cout << "You have entered an invalid option, please try again.\n\n";
184. break;
185. }
186. break;
187.
188. case 'c':
189. case 'C':
190. cout << "Welcome to So-and-So Bank Supervising Services!\n" << "Please enter an option:\n\n";
191. //Cascading banker and customer data
192. //a.Everything in Bank Teller Interface, plus
193. cout << "A)Ability to List Total Number of Customers in Bank\n"
194. << "B)Ability to List Total Amount of Money in the Bank\n"
195. << "C)Ability to List Total Deposits in a Day\n"
196. << "D)Ability to List Total Withdrawals in a Day\n"
197. << "E)Ability to see/query detailed LOG of all transactions\n"
198. << "F)Quit the application\n\n";
199. cin >> choice;
200.
201. switch(choice)
202. {
203. case 'a':
204. case 'A':
205. //for loop count customers
206. break;
207. case 'b':
208. case 'B':
209. //for loop count money
210. break;
211. case 'c':
212. case 'C':
213. //for loop count deposits (amount?)
214. break;
215. case 'd':
216. case 'D':
217. //for loop count withdrawals (amount?)
218. break;
219. case 'e':
220. case 'E':
221. //enum results from b,c, and d. for loop allow search
222. break;
223. case 'f':
224. case 'F':
225. cout << "You have chosen to quit, we appreciate your business.";
226. terminate = true;
227. break;
228. default:
229. cout << "You have entered an invalid option, please try again.\n\n";
230. break;
231. }
232. break;
233.
234. case 'd':
235. case 'D':
236. cout << "You have chosen to quit, we appreciate your business.";
237. terminate = true;
238. break;
239.
240. default:
241. cout << "You have entered an invalid option, please try again.\n\n";
242. break;
243. }
244.
245. }
246.return 0;
247.}