1. You don't includeusingnamespace std; so "cout" and "cin" are not recognized.
2. You use the wrong data type for your "vote" variable; it should be a 'char'.
3. You need to use single quotes in your if statements when comparing characters.
Also your program will only record 1 vote; I'm not sure if that's what you want.
// Example program
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
int DJ = 0;
int Casey = 0;
char vote;
cout << "Pick your favorite Jaws brother\n Type D to vote for DJ. \n Type C to vote for Casey \n Type an E When Voting is Complete \n";
cin >> vote;
if (vote == 'D')
DJ++;
elseif (vote == 'C')
Casey++;
elseif (vote == 'E')
cout << "Voting is complete!" << endl;
if (DJ > Casey)
cout << "The Winner is DJ!!";
elseif (Casey > DJ)
cout << "The Winner is Casey!!";
system("pause");
return 0;
}
1. You don't include using namespace std; so "cout" and "cin" are not recognized.
The OP certainly did, however it is advised to avoid including entire namespaces and instead to locally scope to them via the :: operator e.g. std::cout.
do
{
//stuff to repeat (get the input)
} while(input != EscapeSequence);
1 2 3 4 5
if (DJ > Casey)
cout << "The Winner is DJ!!";
elseif (Casey > DJ)
cout << "The Winner is Casey!!";
What happens when DJ is equal to Casey? (Hint: nothing, so you may want to add in that case)
One last thing, you should avoid using system("anything");
Oh, and @OP please put in more descriptive information when posting questions here. "This voting program isn't working. What am I doing wrong?" is very vague and you don't even mention what your end goal is or what the assignment is. If you would please post that next time or even update yours that would be more helpful for us and for you. Keep in mind this isn't a website to do homework for you but to assist you.