Compiler error on survey program

Hi, I'n nearly done this program. It's a survey that tallys all the votes from multiple entries and produces winners as well as ties. I'm getting a compiler error that is saying that it expects an identifier before the '(' token.

It starts on line 45 at the first if statement and carries on for each else if as well.

Thanks in advance for the help!

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

using namespace std;
int main() 
	
{
	
	int i,players,vote,totalwii,totalxbox,totalplay = 0;
	cout << "Welcome to the game console survey" << endl;
	cout << "Enter the total number of participants: ";
	cin >> players;
	
	cout << "THe available consoles are: ";
	cout << "\n1. Nintentdo Wii";
	cout << "\n2. Microsoft X-box one";
	cout << "\n3. Sony Playstation 4" << endl;
	cout << "\nIf you prefer Nintendo Wii, enter 1.";	
	cout << "\nIf you prefer Microsoft X-box one, enter 2.";	
	cout << "\nIf you prefer Sony Playstation 4, enter 3." << endl;
	
	for (i=0 ; i < players ; i++)
	{
		cout << "\nParticipant #" << (i+1) << ", Enter your favourite game console choice: ";
		cin >> vote;
		
		if (vote == 1) 
		{
			totalwii++;
		}
		else if (vote == 2)
		{
			totalxbox++;
		}
		else if (vote == 3)
		{
			totalplay++;
		}
		
	}
	
	cout << "Results of the survey ------------------->" << endl;
	cout << "Total participants: " << players << endl;
	
	
	if (totalwii > totalxbox) && (totalwii > totalplay) && (totalxbox > totalplay)
		{
			cout << "Nintento 1st " << totalwii << endl;
			cout << "X-box 2nd " << totalxbox << endl;
			cout << "Sony 3rd " << totalplay << endl;
			cout << "Thanks for your participation :) " << endl;	
		}
	else if (totalwii > totalxbox) && (totalwii > totalplay) && (totalxbox < totalplay)
		{
			cout << "Nintento 1st " << totalwii << endl;
			cout << "Sony 2nd " << totalplay << endl;
			cout << "X-box 3rd " << totalxbox << endl;
			cout << "Thanks for your participation :) " << endl;	
		}	
	else if (totalwii > totalxbox) && (totalwii > totalplay) && (totalxbox > totalplay)
		{
			cout << "Nintento 1st " << totalwii << endl;
			cout << "X-box 2nd " << totalxbox << endl;
			cout << "Sony 3rd " << totalplay << endl;
			cout << "Thanks for your participation :) " << endl;		
		}
	else if (totalwii > totalxbox) && (totalwii == totalplay)
		{
			cout << "Nintento 1st " << totalwii << endl;
			cout << "X-box and Sony tied for 2nd " << totalxbox << endl;
			cout << "Thanks for your participation :) " << endl;
		}
	else if (totalxbox > totalwii) && (totalxbox > totalplay) && (totalwii > totalplay)
		{
			cout << "X-box 1st " << totalxbox << endl;
			cout << "Nintendo 2nd " << totalwii << endl;
			cout << "Sony 3rd " << totalplay << endl;
			cout << "Thanks for your participation :) " << endl;
		}
	else if (totalxbox > totalwii) && (totalxbox > totalplay) && (totalwii < totalplay)
		{
			cout << "X-box 1st " << totalxbox << endl;
			cout << "Sony 2nd " << totalplay << endl;
			cout << "Nintendo 3rd " << totalwii << endl;
			cout << "Thanks for your participation :) " << endl;
		}
	else if (totalxbox > totalwii) && (totalxbox == totalplay)
		{
			cout << "X-box 1st " << totalxbox << endl;
			cout << "Nintendo and Sony tied for 2nd " << totalwii << endl;
			cout << "Thanks for your participation :) " << endl;
		}
	else if (totalplay > totalxbox) && (totalplay > totalwii) && (totalwii > totalxbox)
		{
			cout << "Sony 1st " << totalplay << endl;
			cout << "Nintendo 2nd " << totalwii << endl;
			cout << "X-box 3rd " << totalxbox << endl;
			cout << "Thanks for your participation :) " << endl;
		}
	else if (totalplay > totalxbox) && (totalplay > totalwii) && (totalwii < totalxbox)
		{
			cout << "Sony 1st " << totalplay << endl;
			cout << "X-box 2nd " << totalxbox << endl;
			cout << "NIntendo 3rd " << totalwii << endl;
			cout << "Thanks for your participation :) " << endl;
		}
	else if (totalplay > totalxbox) && (totalplay == totalwii)
		{
			cout << "Sony 1st " << totalplay << endl;
			cout << "Nintendo and X-box tied for 2nd " << totalwii << endl;
			cout << "Thanks for your participation :) " << endl;
		}
	else if (totalplay == totalxbox) && (totalplay == totalwii) && (totalxbox == totalwii)
		{
			cout << "All three received equal votes " << totalplay << endl;
			cout << "Thanks for your participation :) " << endl;
		}

	return 0;
		
}




Try putting one big parenthesis on all the if and else if statements because when you put
if (totalxbox > totalwii) && (blah > blah)
you only apply the if to the first one think of it like math distributing, you only distribute the "if" to the first parenthesis. so try it like this
if ((totalxbox > totalwii) && (blah > blah))
I'm no expert so I might be wrong but i''m sure thats how you do it :)
Topic archived. No new replies allowed.