I keep playing with this program, and I can't compile anymore

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
#include <iostream>

using namespace std;
//include protype functions
enum AccountType 
{unknown = -1, Checking, Savings, CreditCard, InstantAccess};

struct customerInfo 
	{
		char firstName[20]; 
		char lastName[20];
		float amount;
		AccountType type;
	}

int main()
{
	char choice;
	bool terminate = false;
	int i = 0;
	const int SIZE = 100;

	customerInfo[SIZE];

	//float depositAmount (){};
	//float withdrawAmount (){};

	while (!terminate)
	{
		cout << "WELCOME TO SO-AND-SO BANK!\n\n" << "Please enter an option, are you a:\n\n" 
		<< "A)Customer\n" 
		<< "B)Bank Employee\n" 
		<< "C)Bank Supervisor\n" 
		<< "D)Quit the application\n\n";
		cin >> choice;

		switch(choice)
		{
		case 'a':
		case 'A':
		cout << "Welcome to So-and-So Bank Customer Services!\n" << "Please enter an option:\n\n";
		//Customer options
		cout << "A)Functions: Balance Inquiry\n" 
		<< "B)Deposit Funds\n" 
		<< "C)Withdraw funds\n"
		<< "D)Transfer Funds to another account (like from Checking to Savings or to Credit Card)\n"
		<< "E)Anything else that you want to add\n" 
		<< "F)Quit the application\n\n";
		cin >> choice;

		switch(choice)
		{
		case 'a':
		case 'A':
			//struct name, amount, type
			for(i = 0; i < SIZE; i++) //edit
			{
				cout << "Enter your first name (20 characters or less):\n\n";
				cin >> customerInfo[i].firstName;
				cout << "Enter your last name (20 characters or less):\n\n";
				cin >> customerInfo[i].lastName;
			};

			break;
		case 'b':
		case 'B':
			//depositAmount();
			break;
		case 'c':
		case 'C':
			//withdrawAmount();
			break;
		case 'd':
		case 'D':
			//transfer enum
			break;
		case 'e':
		case 'E':
			//while or goto loop
			break;
		case 'f':
		case 'F':
		cout << "You have chosen to quit, we appreciate your business.";
		terminate = true;
			break;
		default:
		cout << "You have entered an invalid option, please try again.\n\n";
			break;
		}
		break;

		case 'b':
		case 'B':
		cout << "Welcome to So-and-So Bank Employee Services!\n" << "Please enter an option:\n\n";
		//Cascading customer data
		//a.Everything in the Customer Interface, plus
		cout << "A)Interface to ADD a new Customer to the Bank\n"
		<< "B)Interface to DELETE a  Customer from the Bank\n"
		<< "C)Search for a Record based on a “Name of a Customer” (using simple Sequential Search)\n"
		<< "D)Quit the application\n\n";
		cin >> choice;

		switch(choice)
		{
		case 'a':
		case 'A':
			//struct new customer
			for(i = 0; i < SIZE; i++) //edit
			{
				cout << "Enter your first name (20 characters or less):\n\n";
				cin >> customerInfo[i].firstName;
				cout << "Enter your last name (20 characters or less):\n\n";
				cin >> customerInfo[i].lastName;
			};
			break;
		case 'b':
		case 'B':
			//struct delete customer (Case C w/ remove name)
			break;
		case 'c':
		case 'C':
			//for loop name search, cin i, i customer
			cout << "So-and-So Bank Customers:\n";
			for(i = 0; i < SIZE; i++)
			{
				cout << i << ". " << customerInfo[i].lastName << ", " << customerInfo[i].firstName << "\n";
			};
			cout << "Select customer number:\n\n";
			cin >> i;

			cout << customerInfo[i];
			
			break;
		case 'd':
		case 'D':
		cout << "You have chosen to quit, we appreciate your business.";
		terminate = true;
			break;
		default:
		cout << "You have entered an invalid option, please try again.\n\n";
			break;
		}
		break;

		case 'c':
		case 'C':
		cout << "Welcome to So-and-So Bank Supervising Services!\n" << "Please enter an option:\n\n";
		//Cascading banker and customer data
		//a.Everything in Bank Teller Interface, plus
		cout << "A)Ability to List Total Number of Customers in Bank\n"
		<< "B)Ability to List Total Amount of Money in the Bank\n"
		<< "C)Ability to List Total Deposits in a Day\n"
		<< "D)Ability to List Total Withdrawals in a Day\n"
		<< "E)Ability to see/query detailed LOG of all transactions\n"
		<< "F)Quit the application\n\n";
		cin >> choice;

		switch(choice)
		{
		case 'a':
		case 'A':
			//for loop count customers
			break;
		case 'b':
		case 'B':
			//for loop count money 
			break;
		case 'c':
		case 'C':
			//for loop count deposits (amount?)
			break;
		case 'd':
		case 'D':
			//for loop count withdrawals (amount?)
			break;
		case 'e':
		case 'E':
			//enum results from b,c, and d. for loop allow search
			break;
		case 'f':
		case 'F':
		cout << "You have chosen to quit, we appreciate your business.";
		terminate = true;
			break;
		default:
		cout << "You have entered an invalid option, please try again.\n\n";
			break;
		}
		break;

		case 'd':
		case 'D':
		cout << "You have chosen to quit, we appreciate your business.";
		terminate = true;
		break;

		default:
		cout << "You have entered an invalid option, please try again.\n\n";
		break;
		}

	}
return 0;
}
Compiler errors, plz.
1>------ Build started: Project: CS162Assignment1, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(29) : error C2628: 'customerInfo' followed by 'int' is illegal (did you forget a ';'?)
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(30) : error C3874: return type of 'main' should be 'int' instead of 'customerInfo'
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(36) : error C2143: syntax error : missing ';' before '['
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(36) : error C2337: 'SIZE' : attribute not found
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(72) : error C2275: 'customerInfo' : illegal use of this type as an expression
1> c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(22) : see declaration of 'customerInfo'
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(72) : error C2228: left of '.firstName' must have class/struct/union
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(74) : error C2275: 'customerInfo' : illegal use of this type as an expression
1> c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(22) : see declaration of 'customerInfo'
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(74) : error C2228: left of '.lastName' must have class/struct/union
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(124) : error C2275: 'customerInfo' : illegal use of this type as an expression
1> c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(22) : see declaration of 'customerInfo'
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(124) : error C2228: left of '.firstName' must have class/struct/union
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(126) : error C2275: 'customerInfo' : illegal use of this type as an expression
1> c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(22) : see declaration of 'customerInfo'
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(126) : error C2228: left of '.lastName' must have class/struct/union
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(139) : error C2275: 'customerInfo' : illegal use of this type as an expression
1> c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(22) : see declaration of 'customerInfo'
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(139) : error C2228: left of '.lastName' must have class/struct/union
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(139) : error C2275: 'customerInfo' : illegal use of this type as an expression
1> c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(22) : see declaration of 'customerInfo'
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(139) : error C2228: left of '.firstName' must have class/struct/union
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(144) : error C2275: 'customerInfo' : illegal use of this type as an expression
1> c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(22) : see declaration of 'customerInfo'
1>c:\users\b\documents\visual studio 2008\projects\cs162assignment1\cs162assignment1\main.cpp(216) : error C2440: 'return' : cannot convert from 'int' to 'customerInfo'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>Build log was saved at "file://c:\Users\b\Documents\Visual Studio 2008\Projects\CS162Assignment1\CS162Assignment1\Debug\BuildLog.htm"
1>CS162Assignment1 - 18 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Hey, trivial errors...
At line 14 you forgot to add ; after the } from the struct
at line 23 customerInfo[SIZE]; you want to make an instance of that struct, so you do something like this customerInfo MYSTRUCT[SIZE] and you use MYSTRUCT.whatever_you_have_in_that_struct.

I made it customerInfo MYSTRUCT[SIZE]

and at line 131, you typed customerInfo[i]. It's wrong. you need to have something like

cout<< MYSTRUCT.a_thing_in_your_struct[i];

I commented that line. I don't know what you want there. and here is the code without errors.



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
#include <iostream>

using namespace std;
//include protype functions
enum AccountType 
{unknown = -1, Checking, Savings, CreditCard, InstantAccess};

struct customerInfo 
	{
		char firstName[20]; 
		char lastName[20];
		float amount;
		AccountType type;
	};

int main()
{
	char choice;
	bool terminate = false;
	int i = 0;
	const int SIZE = 100;

	customerInfo MYSTRUCT[SIZE];

	//float depositAmount (){};
	//float withdrawAmount (){};

	while (!terminate)
	{
		cout << "WELCOME TO SO-AND-SO BANK!\n\n" << "Please enter an option, are you a:\n\n" 
		<< "A)Customer\n" 
		<< "B)Bank Employee\n" 
		<< "C)Bank Supervisor\n" 
		<< "D)Quit the application\n\n";
		cin >> choice;

		switch(choice)
		{
		case 'a':
		case 'A':
		cout << "Welcome to So-and-So Bank Customer Services!\n" << "Please enter an option:\n\n";
		//Customer options
		cout << "A)Functions: Balance Inquiry\n" 
		<< "B)Deposit Funds\n" 
		<< "C)Withdraw funds\n"
		<< "D)Transfer Funds to another account (like from Checking to Savings or to Credit Card)\n"
		<< "E)Anything else that you want to add\n" 
		<< "F)Quit the application\n\n";
		cin >> choice;

		switch(choice)
		{
		case 'a':
		case 'A':
			//struct name, amount, type
			for(i = 0; i < SIZE; i++) //edit
			{
				cout << "Enter your first name (20 characters or less):\n\n";
				cin >> MYSTRUCT[i].firstName;
				cout << "Enter your last name (20 characters or less):\n\n";
				cin >> MYSTRUCT[i].lastName;
			};

			break;
		case 'b':
		case 'B':
			//depositAmount();
			break;
		case 'c':
		case 'C':
			//withdrawAmount();
			break;
		case 'd':
		case 'D':
			//transfer enum
			break;
		case 'e':
		case 'E':
			//while or goto loop
			break;
		case 'f':
		case 'F':
		cout << "You have chosen to quit, we appreciate your business.";
		terminate = true;
			break;
		default:
		cout << "You have entered an invalid option, please try again.\n\n";
			break;
		}
		break;

		case 'b':
		case 'B':
		cout << "Welcome to So-and-So Bank Employee Services!\n" << "Please enter an option:\n\n";
		//Cascading customer data
		//a.Everything in the Customer Interface, plus
		cout << "A)Interface to ADD a new Customer to the Bank\n"
		<< "B)Interface to DELETE a  Customer from the Bank\n"
		<< "C)Search for a Record based on a “Name of a Customer” (using simple Sequential Search)\n"
		<< "D)Quit the application\n\n";
		cin >> choice;

		switch(choice)
		{
		case 'a':
		case 'A':
			//struct new customer
			for(i = 0; i < SIZE; i++) //edit
			{
				cout << "Enter your first name (20 characters or less):\n\n";
				cin >> MYSTRUCT[i].firstName;
				cout << "Enter your last name (20 characters or less):\n\n";
				cin >> MYSTRUCT[i].lastName;
			};
			break;
		case 'b':
		case 'B':
			//struct delete customer (Case C w/ remove name)
			break;
		case 'c':
		case 'C':
			//for loop name search, cin i, i customer
			cout << "So-and-So Bank Customers:\n";
			for(i = 0; i < SIZE; i++)
			{
				cout << i << ". " << MYSTRUCT[i].lastName << ", " << MYSTRUCT[i].firstName << "\n";
			};
			cout << "Select customer number:\n\n";
			cin >> i;

			//cout << MYSTRUCT[i].amount;
			
			break;
		case 'd':
		case 'D':
		cout << "You have chosen to quit, we appreciate your business.";
		terminate = true;
			break;
		default:
		cout << "You have entered an invalid option, please try again.\n\n";
			break;
		}
		break;

		case 'c':
		case 'C':
		cout << "Welcome to So-and-So Bank Supervising Services!\n" << "Please enter an option:\n\n";
		//Cascading banker and customer data
		//a.Everything in Bank Teller Interface, plus
		cout << "A)Ability to List Total Number of Customers in Bank\n"
		<< "B)Ability to List Total Amount of Money in the Bank\n"
		<< "C)Ability to List Total Deposits in a Day\n"
		<< "D)Ability to List Total Withdrawals in a Day\n"
		<< "E)Ability to see/query detailed LOG of all transactions\n"
		<< "F)Quit the application\n\n";
		cin >> choice;

		switch(choice)
		{
		case 'a':
		case 'A':
			//for loop count customers
			break;
		case 'b':
		case 'B':
			//for loop count money 
			break;
		case 'c':
		case 'C':
			//for loop count deposits (amount?)
			break;
		case 'd':
		case 'D':
			//for loop count withdrawals (amount?)
			break;
		case 'e':
		case 'E':
			//enum results from b,c, and d. for loop allow search
			break;
		case 'f':
		case 'F':
		cout << "You have chosen to quit, we appreciate your business.";
		terminate = true;
			break;
		default:
		cout << "You have entered an invalid option, please try again.\n\n";
			break;
		}
		break;

		case 'd':
		case 'D':
		cout << "You have chosen to quit, we appreciate your business.";
		terminate = true;
		break;

		default:
		cout << "You have entered an invalid option, please try again.\n\n";
		break;
		}

	}
return 0;
}
Last edited on
1.as the first two errors let us expect: your forgot the ";" behind your CustomerInfo-structure... creating a new type is an instruction that needs to be terminated with ";"...

2. customerInfo[SIZE]; ... if u want to create an array of customerInfo´s then customerInfo is the type and not the declarato^^ so customerInfo customerInfoArray[SIZE]; would we the one u wanted^^... and then replay all the "customerInfo" with "customerInfoArray";


darn, too late:D...
Last edited on
Thank you everybody, I'm still trying to get used the array structs and whatnot
Topic archived. No new replies allowed.