Help Me Voting program C++

I just want to adding "How Many Candidate" .... that we can choose how many candidates we want ....
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
[output]#include<iostream.h>
#include <conio.h>
#include<stdio.h>
int main()
{
int candidate, A;
int X[100];
float votes1=0,votes2=0,percent1,percent2;
char again;
char program[20], a[20], b[20];
cout<<"Please enter name of voting program"<<endl;
cout<<"Voting for :"; gets(program);
cout<<"How many candidate you want:";cin>>X[A];
if(X[A]==A)
{
cout<<"Enter candidate :"; gets(a); cout<<endl;
}

cout<<"\tProgram Voting untuk "<<program<<endl;
cout<<"============================================================================"<<endl;
do
{
cout<<"Masukan banyaknya candidate:"<<endl;
cout<<"Candidate 1:"<<a<<endl;
cout<<"Candidate 2:"<<b<<endl;
cout<<endl;
cout<<endl;
cout<<"Which One you want vote Candidate 1 or Candidate 2:"<<endl;
cout<<"Candidate "; cin>>candidate;

if(candidate == 1)
{
candidate=votes1;
votes1++;
percent1=votes1/(votes1+votes2)*100;
percent2=votes2/(votes1+votes2)*100;
cout<<"Voting for"<<a<<" is\t"<<votes1<<"("<<percent1<<"%)"<<endl;
cout<<"Voting for"<<b<<" is\t"<<votes2<<"("<<percent2<<"%)"<<endl;
}
else if (candidate == 2)
{
candidate=votes2;
votes2++;
percent1=votes1/(votes1+votes2)*100;
percent2=votes2/(votes1+votes2)*100;
cout<<"Voting for"<<a<<"is\t"<<votes1<<"("<<percent1<<"%)"<<endl;
cout<<"Voting for"<<b<<" is\t"<<votes2<<"("<<percent2<<"%)"<<endl;
}
else
{
cout<<"Your input is invalid"<<endl;
}
cout<<"Voting Again?"; cin>>again;
clrscr();
}while(again == 'y');
percent1=votes1/(votes1+votes2)*100;
percent2=votes2/(votes1+votes2)*100;

cout<<"The last result for Voting is"<<endl;
cout<<endl;
cout<<endl;
cout<<"Voting for "<<a<<" is\t"<<percent1<<"%"<<endl;
cout<<"Voting for "<<b<<" is\t"<<percent2<<"%"<<endl;
if(percent1>percent2)
{
cout<<"The Winner" <<a<<" !!!! with percentage:"<<percent1<<"%"<<endl;
cout<<endl;
cout<<"Congratulations for the winner ^^"<<endl;
}
else
{
cout<<"The last result for Voting is"<<endl;
cout<<endl;
cout<<endl;
cout<<"The Winner Is "<<b<<" !!!! with percentage:"<<percent2<<"%"<<endl;
cout<<endl;
cout<<"Congratulations for the winner ^^"<<endl;
}

return 0;
}
#include<iostream.h>
#include <conio.h>
#include<stdio.h>
int main()
{
int candidate, A;
int X[100];
float votes1=0,votes2=0,percent1,percent2;
char again;
char program[20], a[20], b[20];
cout<<"Silahkan masukan nama program voting"<<endl;
cout<<"Voting for :"; gets(program);
cout<<"Silahkan masukan banyaknya kandidat";cin>>X[A];
if(X[A]==A)
{
cout<<"Enter candidate :"; gets(a); cout<<endl;
}

cout<<"\tProgram Voting untuk "<<program<<endl;
cout<<"============================================================================"<<endl;
do
{
cout<<"How Many candidate:"<<endl;
cout<<"Candidate 1:"<<a<<endl;
cout<<"Candidate 2:"<<b<<endl;
cout<<endl;
cout<<endl;
cout<<"Which One you want vote Candidate 1 or Candidate 2:"<<endl;
cout<<"Candidate "; cin>>candidate;

if(candidate == 1)
{
candidate=votes1;
votes1++;
percent1=votes1/(votes1+votes2)*100;
percent2=votes2/(votes1+votes2)*100;
cout<<"Voting for"<<a<<" is\t"<<votes1<<"("<<percent1<<"%)"<<endl;
cout<<"Voting for"<<b<<" is\t"<<votes2<<"("<<percent2<<"%)"<<endl;
}
else if (candidate == 2)
{
candidate=votes2;
votes2++;
percent1=votes1/(votes1+votes2)*100;
percent2=votes2/(votes1+votes2)*100;
cout<<"Voting for"<<a<<"is\t"<<votes1<<"("<<percent1<<"%)"<<endl;
cout<<"Voting for"<<b<<" is\t"<<votes2<<"("<<percent2<<"%)"<<endl;
}
else
{
cout<<"Your input is invalid"<<endl;
}
cout<<"Voting Again?"; cin>>again;
clrscr();
}while(again == 'y');
percent1=votes1/(votes1+votes2)*100;
percent2=votes2/(votes1+votes2)*100;

cout<<"The last result for Voting is"<<endl;
cout<<endl;
cout<<endl;
cout<<"Voting for "<<a<<" is\t"<<percent1<<"%"<<endl;
cout<<"Voting for "<<b<<" is\t"<<percent2<<"%"<<endl;
if(percent1>percent2)
{
cout<<"The Winner" <<a<<" !!!! with percentage:"<<percent1<<"%"<<endl;
cout<<endl;
cout<<"Congratulations for the winner ^^"<<endl;
}
else
{
cout<<"The last result for Voting is"<<endl;
cout<<endl;
cout<<endl;
cout<<"The Winner Is "<<b<<" !!!! with percentage:"<<percent2<<"%"<<endl;
cout<<endl;
cout<<"Congratulations for the winner ^^"<<endl;
}

return 0;
}


Last edited on
#include<iostream.h>
#include <conio.h>
#include<stdio.h>
int main()
{
int candidate, A;
int X[100];
float votes1=0,votes2=0,percent1,percent2;
char again;
char program[20], a[20], b[20];
cout<<"Please enter name of voting program"<<endl;
cout<<"Voting for :"; gets(program);
cout<<"How many candidate you want:";cin>>X[A];
if(X[A]==A)
{
cout<<"Enter candidate :"; gets(a); cout<<endl;
}

cout<<"\tProgram Voting untuk "<<program<<endl;
cout<<"============================================================================"<<endl;
do
{
cout<<"Masukan banyaknya candidate:"<<endl;
cout<<"Candidate 1:"<<a<<endl;
cout<<"Candidate 2:"<<b<<endl;
cout<<endl;
cout<<endl;
cout<<"Which One you want vote Candidate 1 or Candidate 2:"<<endl;
cout<<"Candidate "; cin>>candidate;

if(candidate == 1)
{
candidate=votes1;
votes1++;
percent1=votes1/(votes1+votes2)*100;
percent2=votes2/(votes1+votes2)*100;
cout<<"Voting for"<<a<<" is\t"<<votes1<<"("<<percent1<<"%)"<<endl;
cout<<"Voting for"<<b<<" is\t"<<votes2<<"("<<percent2<<"%)"<<endl;
}
else if (candidate == 2)
{
candidate=votes2;
votes2++;
percent1=votes1/(votes1+votes2)*100;
percent2=votes2/(votes1+votes2)*100;
cout<<"Voting for"<<a<<"is\t"<<votes1<<"("<<percent1<<"%)"<<endl;
cout<<"Voting for"<<b<<" is\t"<<votes2<<"("<<percent2<<"%)"<<endl;
}
else
{
cout<<"Your input is invalid"<<endl;
}
cout<<"Voting Again?"; cin>>again;
clrscr();
}while(again == 'y');
percent1=votes1/(votes1+votes2)*100;
percent2=votes2/(votes1+votes2)*100;

cout<<"The last result for Voting is"<<endl;
cout<<endl;
cout<<endl;
cout<<"Voting for "<<a<<" is\t"<<percent1<<"%"<<endl;
cout<<"Voting for "<<b<<" is\t"<<percent2<<"%"<<endl;
if(percent1>percent2)
{
cout<<"The Winner" <<a<<" !!!! with percentage:"<<percent1<<"%"<<endl;
cout<<endl;
cout<<"Congratulations for the winner ^^"<<endl;
}
else
{
cout<<"The last result for Voting is"<<endl;
cout<<endl;
cout<<endl;
cout<<"The Winner Is "<<b<<" !!!! with percentage:"<<percent2<<"%"<<endl;
cout<<endl;
cout<<"Congratulations for the winner ^^"<<endl;
}

return 0;
}
#include<iostream.h>
#include <conio.h>
#include<stdio.h>
int main()
{
int candidate, A;
int X[100];
float votes1=0,votes2=0,percent1,percent2;
char again;
char program[20], a[20], b[20];
cout<<"Silahkan masukan nama program voting"<<endl;
cout<<"Voting for :"; gets(program);
cout<<"Silahkan masukan banyaknya kandidat";cin>>X[A];
if(X[A]==A)
{
cout<<"Enter candidate :"; gets(a); cout<<endl;
}

cout<<"\tProgram Voting untuk "<<program<<endl;
cout<<"============================================================================"<<endl;
do
{
cout<<"How Many candidate:"<<endl;
cout<<"Candidate 1:"<<a<<endl;
cout<<"Candidate 2:"<<b<<endl;
cout<<endl;
cout<<endl;
cout<<"Which One you want vote Candidate 1 or Candidate 2:"<<endl;
cout<<"Candidate "; cin>>candidate;

if(candidate == 1)
{
candidate=votes1;
votes1++;
percent1=votes1/(votes1+votes2)*100;
percent2=votes2/(votes1+votes2)*100;
cout<<"Voting for"<<a<<" is\t"<<votes1<<"("<<percent1<<"%)"<<endl;
cout<<"Voting for"<<b<<" is\t"<<votes2<<"("<<percent2<<"%)"<<endl;
}
else if (candidate == 2)
{
candidate=votes2;
votes2++;
percent1=votes1/(votes1+votes2)*100;
percent2=votes2/(votes1+votes2)*100;
cout<<"Voting for"<<a<<"is\t"<<votes1<<"("<<percent1<<"%)"<<endl;
cout<<"Voting for"<<b<<" is\t"<<votes2<<"("<<percent2<<"%)"<<endl;
}
else
{
cout<<"Your input is invalid"<<endl;
}
cout<<"Voting Again?"; cin>>again;
clrscr();
}while(again == 'y');
percent1=votes1/(votes1+votes2)*100;
percent2=votes2/(votes1+votes2)*100;

cout<<"The last result for Voting is"<<endl;
cout<<endl;
cout<<endl;
cout<<"Voting for "<<a<<" is\t"<<percent1<<"%"<<endl;
cout<<"Voting for "<<b<<" is\t"<<percent2<<"%"<<endl;
if(percent1>percent2)
{
cout<<"The Winner" <<a<<" !!!! with percentage:"<<percent1<<"%"<<endl;
cout<<endl;
cout<<"Congratulations for the winner ^^"<<endl;
}
else
{
cout<<"The last result for Voting is"<<endl;
cout<<endl;
cout<<endl;
cout<<"The Winner Is "<<b<<" !!!! with percentage:"<<percent2<<"%"<<endl;
cout<<endl;
cout<<"Congratulations for the winner ^^"<<endl;
}

return 0;
}

Your help is very helping me :) ... thx
Topic archived. No new replies allowed.