Election program sytem.

Hi guys, i really need your help about this topic. My project is Election program system. How do i divide Candidates into a Partylist? and Also the tally system is not perfect, it needs to count at least 30 Voters to sum up the votes.
heres the code:

#include<stdio.h>
#include <windows.h>
#include<conio.h>
#include<stdlib.h>

typedef struct{
char name[50];
int id;
}candidates_t;

void candidateInitiallize(candidates_t Cand[58])
{
strcpy(Cand[1].name,"Talandron Job");
strcpy(Cand[2].name,"Lesean Panuncillo");
strcpy(Cand[3].name,"Christian Tolomea");
strcpy(Cand[4].name,"BastidaJohn Paul");
strcpy(Cand[5].name,"");
strcpy(Cand[6].name,"");
strcpy(Cand[7].name,"");
strcpy(Cand[8].name,"");
strcpy(Cand[9].name,"");
strcpy(Cand[10].name,"");
strcpy(Cand[11].name,"");
strcpy(Cand[12].name,"");
strcpy(Cand[13].name,"");
strcpy(Cand[14].name,"");
strcpy(Cand[15].name,"");
strcpy(Cand[16].name,"");
strcpy(Cand[17].name,"");
strcpy(Cand[18].name,"");
strcpy(Cand[19].name,"");
strcpy(Cand[20].name,"");
}

int main()
{
int vote=0,ctr,winner;
int tally[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
for(ctr=1;ctr<=3;ctr++)
{

printf("Voter #: %d\n ",ctr);

candidates_t Cand[20];
int votes[12];
int numberchoosen = 0;
int found=0;
candidateInitiallize(Cand);

int i,j;
int s;
int votee;

{
printf("\n");
printf("\t\t\t\t OFFICIAL BALLOT\n");
printf("\t\t OFFICIAL LIST OF STUDENT COUNCIL CANDIDATES 2014\n");
printf("\t\t\tDON BOSCO TECHNOLOGY CENTER\n\n\n");

printf("1. Talandron Job\n");
printf("2. Lesean Panuncillo\n");
printf("3. Christian Tolomea\n");
printf("4. Bastida John Paul\n");
printf("5. DE LEON, Alveene Joyce\n");
printf("6. ESPELETA, Paola\n");
printf("7. GABALDON, Neil\n");
printf("8. HADAP, Krista\n");
printf("9. JUANO, Jeffrey\n");
printf("10. KIONG, Jennifer\n");
printf("11. LIM, Jeremy\n");
printf("12. LO, Jimmy\n");
printf("13. NG, Robbie\n");
printf("14. ORMOC, Regan\n");
printf("15. PANULAYA, Leonila\n");
printf("16. RECENO, Roy Justin\n");
printf("17. SEVILLA, Nigel\n");
printf("18. TAN, Donald\n");
printf("19. UY, Jocelle\n");
printf("20. VELASCO, Anton\n\n");

system("pause");
system("cls");

printf("INSTRUCTION:\n");
printf("TO VOTE FOR A CANDIDATE,INPUT THE NUMBER CORRESPONDING TO YOUR\n");
printf("CHOSEN STUDENCT COUNCIL CANDIDATE.\n\n");
printf("Enter Candidate Number (1-20) you want to Vote: \n\n\n");

{
for(i=0;i<12;i++)
{
printf("Vote: ");
scanf("%d",&votes[i]);

//scan if napili na or hindi
found = 0;
for(j=0;j<numberchoosen;j++)
{
if(votes[i] == votes[j])
{
printf("Invalid Vote! Please Try Again\n");
found = 1;
}
else if (votes[i]>20)
{
printf("Invalid Vote! Please Try Again\n");
found = 1;
}
}

if(found == 0)
{
numberchoosen++;
}
else{
i--;
}
}
system("cls");
printf("You're Elected Candidates: \n\n");
for(i=0;i<12;i++)
{
printf("%s\n",Cand[votes[i]].name);
}
printf("\n\n");
system("pause");
system("cls");
printf("CONGRATULATIONS! YOUR VOTE HAS BEEN ACCEPTED!\n");
printf("THE NEXT VOTER WILL NOW INPUT HIS/HER VOTE.\n");
printf("THANK YOU FOR VOTING!\n");
printf("\n\n");
system("pause");
system("cls");
}
}
tally[vote-1]++;
}

for(ctr=0;ctr<20;ctr++)
{
switch(ctr)
{
case 1:printf("AQUINO, Juan Gabriel got %d votes\n",tally[ctr]++);
break;
case 2:printf("ASUNCION, Beal got %d votes\n",tally[ctr]++);
break;
case 3:printf("CHONG, Jessica got %d votes\n",tally[ctr]++);
break;
case 4:printf("DACANAY, Therese got %d votes\n",tally[ctr]++);
break;
case 5:printf("DE LEON, Alveene Joyce got %d votes\n",tally[ctr]++);
break;
case 6:printf("ESPELETA, Paola got %d votes\n",tally[ctr]++);
break;
case 7:printf("GABALDON, Neil got %d votes\n",tally[ctr]++);
break;
case 8:printf("HADAP, Krista got %d votes\n",tally[ctr]++);
break;
case 9:printf("JUANO, Jeffrey got %d votes\n",tally[ctr]++);
break;
case 10:printf("KIONG, Jennifer got %d votes\n",tally[ctr]++);
break;
case 11:printf("LIM, Jeremy got %d votes\n",tally[ctr]++);
break;
case 12:printf("LO, Jimmy got %d votes\n",tally[ctr]++);
break;
case 13:printf("NG, Robbie got %d votes\n",tally[ctr]++);
break;
case 14:printf("ORMOC, Regan got %d votes\n",tally[ctr]++);
break;
case 15:printf("PANULAYA, Leonila got %d votes\n",tally[ctr]++);
break;
case 16:printf("RECENO, Roy Justin got %d votes\n",tally[ctr]++);
break;
case 17:printf("SEVILLA, Nigel got %d votes\n",tally[ctr]++);
break;
case 18:printf("TAN, Donald got %d votes\n",tally[ctr]++);
break;
case 19:printf("UY, Jocelle got %d votes\n",tally[ctr]++);
break;
case 20:printf("VELASCO, Anton got %d votes\n",tally[ctr]++);
break;
}
}
winner=0;
for(ctr=0;ctr<20;ctr++)
{
if(tally[winner]<tally[ctr])
winner=ctr;
}
switch(winner)
{
case 1:printf("The winner is AQUINO, Juan Gabriel\n");
case 2:printf("The winner is ASUNCION, Beal\n");
case 3:printf("The winner is CHONG, Jessica\n");
case 4:printf("The winner is DACANAY, Therese\n");
case 5:printf("The winner is DE LEON, Alveene Joyce\n");
case 6:printf("The winner is ESPELETA, Paola\n");
case 7:printf("The winner is GABALDON, Neil\n");
case 8:printf("The winner is HADAP, Krista\n");
case 9:printf("The winner is JUANO, Jeffrey\n");
case 10:printf("The winner is KIONG, Jennifer\n");
case 11:printf("The winner is LIM, Jeremy\n");
case 12:printf("The winner is LO, Jimmy\n");
case 13:printf("The winner is NG, Robbie\n");
case 14:printf("The winner is ORMOC, Regan\n");
case 15:printf("The winner is PANULAYA, Leonila\n");
case 16:printf("The winner is RECENO, Roy Justin\n");
case 17:printf("The winner is SEVILLA, Nigel\n");
case 18:printf("The winner is TAN, Donald\n");
case 19:printf("The winner is UY, Jocelle\n");
case 20:printf("The winner is VELASCO, Anton\n");
break;
}
system("pause");
return 0;
}
Please use code tags!
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
#include<stdio.h>
#include <windows.h>
#include<conio.h>
#include<stdlib.h>

typedef struct{
char name[50];
int id;
}candidates_t;

void candidateInitiallize(candidates_t Cand[58])
{
strcpy(Cand[1].name,"Talandron Job");
strcpy(Cand[2].name,"Lesean Panuncillo");
strcpy(Cand[3].name,"Christian Tolomea");
strcpy(Cand[4].name,"BastidaJohn Paul");
strcpy(Cand[5].name,"");
strcpy(Cand[6].name,"");
strcpy(Cand[7].name,"");
strcpy(Cand[8].name,"");
strcpy(Cand[9].name,"");
strcpy(Cand[10].name,"");
strcpy(Cand[11].name,"");
strcpy(Cand[12].name,"");
strcpy(Cand[13].name,"");
strcpy(Cand[14].name,"");
strcpy(Cand[15].name,"");
strcpy(Cand[16].name,"");
strcpy(Cand[17].name,"");
strcpy(Cand[18].name,"");
strcpy(Cand[19].name,"");
strcpy(Cand[20].name,"");
}

int main()
{
int vote=0,ctr,winner;
int tally[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
for(ctr=1;ctr<=3;ctr++)
{

printf("Voter #: %d\n ",ctr); 

candidates_t Cand[20];
int votes[12];
int numberchoosen = 0;
int found=0;
candidateInitiallize(Cand);

int i,j;
int s;
int votee;

{
printf("\n");
printf("\t\t\t\t OFFICIAL BALLOT\n");
printf("\t\t OFFICIAL LIST OF STUDENT COUNCIL CANDIDATES 2014\n");
printf("\t\t\tDON BOSCO TECHNOLOGY CENTER\n\n\n");

printf("1. Talandron Job\n");
printf("2. Lesean Panuncillo\n");
printf("3. Christian Tolomea\n");
printf("4. Bastida John Paul\n");
printf("5. DE LEON, Alveene Joyce\n");
printf("6. ESPELETA, Paola\n");
printf("7. GABALDON, Neil\n");
printf("8. HADAP, Krista\n");
printf("9. JUANO, Jeffrey\n");
printf("10. KIONG, Jennifer\n");
printf("11. LIM, Jeremy\n");
printf("12. LO, Jimmy\n");
printf("13. NG, Robbie\n");
printf("14. ORMOC, Regan\n");
printf("15. PANULAYA, Leonila\n");
printf("16. RECENO, Roy Justin\n");
printf("17. SEVILLA, Nigel\n");
printf("18. TAN, Donald\n");
printf("19. UY, Jocelle\n");
printf("20. VELASCO, Anton\n\n");

system("pause");
system("cls");

printf("INSTRUCTION:\n");
printf("TO VOTE FOR A CANDIDATE,INPUT THE NUMBER CORRESPONDING TO YOUR\n");
printf("CHOSEN STUDENCT COUNCIL CANDIDATE.\n\n");
printf("Enter Candidate Number (1-20) you want to Vote: \n\n\n");

{
for(i=0;i<12;i++)
{
printf("Vote: ");
scanf("%d",&votes[i]);

//scan if napili na or hindi
found = 0;
for(j=0;j<numberchoosen;j++)
{
if(votes[i] == votes[j])
{
printf("Invalid Vote! Please Try Again\n");
found = 1;
}
else if (votes[i]>20)
{
printf("Invalid Vote! Please Try Again\n");
found = 1;
}
}

if(found == 0)
{
numberchoosen++;
}
else{
i--;
}
}
system("cls");
printf("You're Elected Candidates: \n\n");
for(i=0;i<12;i++)
{
printf("%s\n",Cand[votes[i]].name);
}
printf("\n\n");
system("pause");
system("cls");
printf("CONGRATULATIONS! YOUR VOTE HAS BEEN ACCEPTED!\n");
printf("THE NEXT VOTER WILL NOW INPUT HIS/HER VOTE.\n");
printf("THANK YOU FOR VOTING!\n");
printf("\n\n");
system("pause"); 
system("cls");
}
}
tally[vote-1]++;
}

for(ctr=0;ctr<20;ctr++)
{
switch(ctr)
{
case 1:printf("AQUINO, Juan Gabriel got %d votes\n",tally[ctr]++);
break;
case 2:printf("ASUNCION, Beal got %d votes\n",tally[ctr]++);
break;
case 3:printf("CHONG, Jessica got %d votes\n",tally[ctr]++);
break;
case 4:printf("DACANAY, Therese got %d votes\n",tally[ctr]++);
break;
case 5:printf("DE LEON, Alveene Joyce got %d votes\n",tally[ctr]++);
break;
case 6:printf("ESPELETA, Paola got %d votes\n",tally[ctr]++);
break;
case 7:printf("GABALDON, Neil got %d votes\n",tally[ctr]++);
break;
case 8:printf("HADAP, Krista got %d votes\n",tally[ctr]++);
break;
case 9:printf("JUANO, Jeffrey got %d votes\n",tally[ctr]++);
break;
case 10:printf("KIONG, Jennifer got %d votes\n",tally[ctr]++);
break;
case 11:printf("LIM, Jeremy got %d votes\n",tally[ctr]++);
break;
case 12:printf("LO, Jimmy got %d votes\n",tally[ctr]++);
break;
case 13:printf("NG, Robbie got %d votes\n",tally[ctr]++);
break;
case 14:printf("ORMOC, Regan got %d votes\n",tally[ctr]++);
break;
case 15:printf("PANULAYA, Leonila got %d votes\n",tally[ctr]++);
break;
case 16:printf("RECENO, Roy Justin got %d votes\n",tally[ctr]++);
break;
case 17:printf("SEVILLA, Nigel got %d votes\n",tally[ctr]++);
break;
case 18:printf("TAN, Donald got %d votes\n",tally[ctr]++);
break;
case 19:printf("UY, Jocelle got %d votes\n",tally[ctr]++);
break;
case 20:printf("VELASCO, Anton got %d votes\n",tally[ctr]++);
break;
}
}
winner=0;
for(ctr=0;ctr<20;ctr++)
{
if(tally[winner]<tally[ctr])
winner=ctr;
}
switch(winner)
{
case 1:printf("The winner is AQUINO, Juan Gabriel\n");
case 2:printf("The winner is ASUNCION, Beal\n");
case 3:printf("The winner is CHONG, Jessica\n");
case 4:printf("The winner is DACANAY, Therese\n");
case 5:printf("The winner is DE LEON, Alveene Joyce\n");
case 6:printf("The winner is ESPELETA, Paola\n");
case 7:printf("The winner is GABALDON, Neil\n");
case 8:printf("The winner is HADAP, Krista\n");
case 9:printf("The winner is JUANO, Jeffrey\n");
case 10:printf("The winner is KIONG, Jennifer\n");
case 11:printf("The winner is LIM, Jeremy\n");
case 12:printf("The winner is LO, Jimmy\n");
case 13:printf("The winner is NG, Robbie\n");
case 14:printf("The winner is ORMOC, Regan\n");
case 15:printf("The winner is PANULAYA, Leonila\n");
case 16:printf("The winner is RECENO, Roy Justin\n");
case 17:printf("The winner is SEVILLA, Nigel\n");
case 18:printf("The winner is TAN, Donald\n");
case 19:printf("The winner is UY, Jocelle\n");
case 20:printf("The winner is VELASCO, Anton\n");
break;
}
system("pause");
return 0;
}
Topic archived. No new replies allowed.