-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.c
406 lines (348 loc) · 10.7 KB
/
main.c
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
typedef struct voter_information
{
char aadhar[20];
char name[50];
char birth_date[15];
struct voter_information *next;
} node;
node *head;
node *space,*start=NULL;
node *search(char x[],char y[],char z[],node *,int *);
node *voter_insert(node *);
node *main_logs(node *);
void admin();
void winner();
void exi();
void voting();
void not_again();
void stop();
void show();
int count=0,R=3,vote=0;
int vote1=0,vote2=0,vote3=0,vote4=0,vote5=0;
int main()
{
while(1){
system("cls");
printf("\n\n\n");
printf("\t ****** WELCOME TO THE ONLINE VOTING PORTAL ****** \n\n");
printf("\t *************************************************** \n\n\n\n\n");
printf(" \t\t *****Please Enter One(1) for logging vote main Logs***** \n\n\n");
int BB;
scanf("%d",&BB);
if(BB==1)
{
start= main_logs(start);
}
}
return 0;
}
node *main_logs(node *start)
{
system("cls");
printf("\n\n\n");
printf(" \t\t\t1. FOR VOTE ENTRY \n");
Sleep(300);
printf(" \t\t\t2. FOR ADMIN PANEL \n");
Sleep(300);
printf(" \t\t\t3. FOR WINNER \n");
printf(" \t IF YOUR CREDENTIALS MATCHES WITH THOSE IN THE VOTER LIST THEN ONLY YOU CAN GIVE YOUR VOTE OTHERWISE YOU CAN NOT \n\n\n");
Sleep(500);
printf(" \t ********So Plz Enter********\n\n\n");
int T;
scanf("%d",&T);
if(T==1)
{
start= voter_insert(start);
}
if(T==2)
{
admin();
}
if(T==3)
{
winner();
}
if(T!=1||T!=2||T!=3)
{
main_logs(start);
}
return start;
}
node *voter_insert(node *start)
{
int UNIVERSAL=0;
int *z;
z = &UNIVERSAL;
node *temp;
char name[50],birth_date[15],aadhar[20];
system("cls");
printf("\n\n\n\n");
printf("\t IF AADHAR ID, YOUR NAME AND YOUR DATE OF BIRTH MATCHES THEN YOU CAN GIVE YOUR VOTE OTHERWISE NOT\n\n");
Sleep(300);
printf("\t\t\t ID YOU DO WRONG %d TIMES, THE PORTAL WILL BE CLOSED AUTOMATICALLY\n\n\n",R);
Sleep(300);
printf("\t\tPlease \n");
Sleep(300);
printf("\t\t\tEnter your AADHAR ID number ");
gets(aadhar);
gets(aadhar);
printf("\t\t\tEnter Your NAME ");
gets(name);
printf("\t\t\tEnter Your BIRTH DATE in dd-mm-yyyy format");
gets(birth_date);
temp=(node *)malloc(sizeof(node));
strcpy(temp->aadhar,aadhar);
strcpy(temp->name,name);
strcpy(temp->birth_date,birth_date);
temp->next=NULL;
head=temp;
while(temp!=NULL)
{
if((strcmp(temp->aadhar,"10001")==0&& strcmp(temp->name,"Rajat Kumar")==0 &&strcmp(temp->birth_date,"31-03-1999")==0) ||
(strcmp(temp->aadhar,"10002")==0&& strcmp(temp->name,"Goutam Kumar Bhadani")==0 &&strcmp(temp->birth_date,"01-01-1999")==0)||
(strcmp(temp->aadhar,"10003")==0&& strcmp(temp->name,"Gautam Kumar")==0 &&strcmp(temp->birth_date,"12-10-1999")==0)||
(strcmp(temp->aadhar,"10004")==0&& strcmp(temp->name,"Kundan Kumar")==0 &&strcmp(temp->birth_date,"08-12-1999")==0)||
(strcmp(temp->aadhar,"10005")==0&& strcmp(temp->name,"Aniket Arora")==0 &&strcmp(temp->birth_date,"28-08-1999")==0)||
(strcmp(temp->aadhar,"10006")==0&& strcmp(temp->name,"Dipika Singh")==0 &&strcmp(temp->birth_date,"20-10-2000")==0)||
(strcmp(temp->aadhar,"10007")==0&& strcmp(temp->name,"Avinash Kumar")==0 &&strcmp(temp->birth_date,"02-03-1999")==0)||
(strcmp(temp->aadhar,"10008")==0&& strcmp(temp->name,"Ravi Raj")==0 &&strcmp(temp->birth_date,"26-12-1999")==0)||
(strcmp(temp->aadhar,"10009")==0&& strcmp(temp->name,"Shubham Kumar")==0 &&strcmp(temp->birth_date,"02-01-1999")==0)||
(strcmp(temp->aadhar,"10010")==0&& strcmp(temp->name,"Subham Kumar")==0 &&strcmp(temp->birth_date,"03-01-1999")==0))
{
R=3;
start=search(temp->aadhar,temp->name,temp->birth_date,start,&UNIVERSAL);
if(UNIVERSAL==0)
{
voting();
}
else
{
not_again();
}
}
else
{
R--;
if(R==0)
{
stop();
break;
}
printf("\n\n\n\n");
printf("\tYour AADHAR ID or NAME or DATE OF BIRTH is wrong\n\n");
Sleep(300);
printf("\t\t\tPlz Re-Enter\n\n");
Sleep(300);
system("pause");
start= main_logs(start);
}
temp=temp->next;
}
return start;
}
void voting()
{
system("cls");
printf("\n\n\n\n");
printf("\t\t * * * * * LIST OF CANDIDATES * * * * * \n\n\n");
Sleep(300);
printf("\t\t\t NAME & THEIR RESPECTIVE SYMBOL\n\n");
Sleep(300);
printf("\t\t\t 1.Mamata Banerjee 1.Fish\n");
Sleep(300);
printf("\t\t\t 2.Deepa Dasmunsi 2.Boat\n");
Sleep(300);
printf("\t\t\t 3.Protima Rajak 3.Motorcycle\n");
Sleep(300);
printf("\t\t\t 4.Joydeb Halder 4.Broomstick\n");
Sleep(300);
printf("\t\t\t 5.Kartik Chandra Ghosh 5.Wheel\n\n\n");
int B,j;
printf("\t\t\t Plzz, \n");
printf("\t\t\t Enter Your Choice \n");
for(j=1;j<=1;j++)
{
scanf("%d",&B);
if(B==1)
{
vote1++;
printf("\n\n\t\t\t\tYOU HAVE SUCCESSFULLY GIVEN YOUR VOTE TO MAMTA BANERJEE\n");
break;
}
if(B==2)
{
vote2++;
printf("\n\n\t\t\t\tYOU HAVE SUCCESSFULLY GIVEN YOUR VOTE TO DEEPA DASMUNSI\n");
break;
}
if(B==3)
{
vote3++;
printf("\n\n\t\t\t\tYOU HAVE SUCCESSFULLY GIVEN YOUR VOTE TO PROTIMA RAJAK\n");
break;
}
if(B==4)
{
vote4++;
printf("\n\n\t\t\t\tYOU HAVE SUCCESSFULLY GIVEN YOUR VOTE TO JOYDEB HALDER\n");
break;
}
if(B==5)
{
vote5++;
printf("\n\n\t\t\t\tYOU HAVE SUCCESSFULLY GIVEN YOUR VOTE TO KARTIK CHANDRA GHOSH\n");
break;
}
if(B!=1||B!=2||B!=3||B!=4||B!=5)
{
printf("\n\t\t************* INVALID CHOICE ENTERED**************\t\t\n");
printf("\n\t\t\tENTER AGAIN\t\t\t\n");
}
}
printf("\n\n**************************THANK YOU***************************\n\n");
printf("press any key");
getch();
}
void admin()
{
int B;
printf("\n\n\n\n");
printf("\t\t\t\t\tEnter Your Password To Unlock The Admin Panel\n\n");
scanf("%d",&B);
if(B==3692)
{
show();
}
else
{
printf("Wrong Password\n");
}
}
void show()
{
int G;
system("cls");
printf("\n\n\n\n");
printf("\t\t\tPresent Vote Count :\n\n");
Sleep(500);
printf("\t\t\t Mamata Banerjee is on %d Votes\n",vote1);
Sleep(500);
printf("\t\t\t Deepa Dasmunsi is on %d Votes\n",vote2);
Sleep(500);
printf("\t\t\t Protima Rajak is on %d Votes\n",vote3);
Sleep(500);
printf("\t\t\t Joydeb Halder is on %d Votes\n",vote4);
Sleep(500);
printf("\t\t\t Kartik Chandra Ghosh is on %d Votes\n\n\n\n",vote5);
Sleep(500);
printf("\t\t\t\t\tEnter Any Key For Main Logs\n\n\t\t\t\t\t\t\tOR\n\n\t\t\t\t\tENTER THE SPECIAL PASSWORD TO CLOSING VOTING PORTAL\n ");
scanf("%d",&G);
if(G==1234)
exi();
else
main_logs(start);
}
void winner()
{
system("cls");
printf("\n\n\n\n");
if(vote2<vote1 && vote3< vote1 && vote4<vote1 && vote5<vote1)
printf("\t\t\tThe present Winner is Mamata Banerjee and she has got %d votes\n\n\n\n",vote1);
if(vote1<vote2 && vote3< vote2 && vote4<vote2 && vote5<vote2)
printf("\t\t\tThe present Winner is Deepa Dasmunsi and she has got %d votes\n\n\n\n",vote2);
if(vote1<vote3 && vote2< vote3 && vote4<vote3 && vote5<vote3)
printf("\t\t\tThe present Winner is Protima Rajak and she has got %d votes\n\n\n\n",vote3);
if(vote1<vote4 && vote2< vote4 && vote3<vote4 && vote5<vote4)
printf("\t\t\tThe present Winner is Joydeb Halder and he has got %d votes\n\n\n\n",vote4);
if(vote1<vote5 && vote2< vote5 && vote3<vote5 && vote4<vote5)
printf("\t\t\tThe present Winner is Kartik Chandra Ghosh and he has got %d votes\n\n\n\n",vote5);
printf("\t\t\t\tEnter Any Key for Main Log\n\n");
getch();
main_logs(start);
}
void stop()
{
system("cls");
printf("\n\n\n\n");
printf("\t\t\t (:-SORRY YOU ENTERED WRONG CREDENTIALS FOR THREE(3) TIMES IN A ROW -:) \n\n\n");
Sleep(500);
printf("\t\t\t Plz try again After A few Moment\n\n\n");
Sleep(500);
printf("\t\t\t * * *Thank You* * * \n\n\n");
Sleep(500);
printf("press any key");
getch();
}
void not_again()
{
int A;
system("cls");
printf("\n\n\n\n");
printf("\t\t\t ***YOU HAVE GIVEN YOUR VOTE SUCCESSFULLY*** \n\n\n");
Sleep(300);
printf("\t\t\t ***YOU CANNOT GIVE YOUR VOTE MORE THAN ONCE*** \n\n\n");
Sleep(300);
printf("\t\t\t If You want to see present winner Enter One(1) or Enter Any Other Key for Main Logs\n\n");
Sleep(300);
scanf("%d",&A);
if(A==1)
{
winner();
}
else
{
main_logs(start);
}
}
void exi()
{
system("cls");
printf("\n\n\n\n\n");
Sleep(500);
printf("\t\t\t ***YOU ARE NOW EXITING THE PORTAL*** \n\n\n");
Sleep(1000);
printf("\t\t\t * * *Thank You For Using This ONLINE PLATFORM For VOTING* * * \n\n\n");
Sleep(1000);
exit(0);
}
node *search(char x[],char y[],char z[],node *start,int *Y)
{
*Y=0;
node *t,*space;
if(start==NULL)
{
space=(node*)malloc(sizeof(node));
strcpy(space->aadhar,x);
strcpy(space->name,y);
strcpy(space->birth_date,z);
start=space;
space->next=NULL;
}
else
{
t=start;
while(t!=NULL)
{
if((strcmp(t->aadhar,x)==0&& strcmp(t->name,y)==0 &&strcmp(t->birth_date,z)==0))
{
*Y=1;
break;
}
t=t->next;
}
if(*Y==0)
{
space=(node*)malloc(sizeof(node));
strcpy(space->aadhar,x);
strcpy(space->name,y);
strcpy(space->birth_date,z);
t=space;
space->next=NULL;
}
}
return start;
}