Iv been working on this program thats due tonight at midnight and I have no idea how to get to work its semi complex any ideas would be great thanks.
David
if (votes for Amanda >= votes for Ben && votes for Cylcone)
{
cout << "Amanada Wins" << endl;
}
else if (votes for Ben >= votes for Amanda && votes for Cylcone)
{
cout << "Ben Wins" << endl;
}
else if (votes for Cyclone >= votes for Ben && votes for Amanda)
{
cout << "Cylcone Wins" << endl;
}
}
system("pause");
return 0;
}
Your problem is that you keep on changing the value of "votes", with your calls to "cin." I know I shouldn't do your work for you, but as long as you understand what is going on, I'm fine.
(Tip: use the "code" tags to place your c++ code in.)
#include <iostream>
usingnamespace std;
int main() {
int votesA, votesB, votesC; // The vote variables, don't use double since you can't really have half of a vote
cout << "Enter votes for Amanda" << endl;
cin >> votesA;
cout << "Enter votes for Ben" << endl;
cin >> votesB;
cout << "Enter votes for Cyclone" << end;
cin >> votesC;
if ((votesA > votesB) && (votesA > votesC)) // For if Amanda wins
cout << "Amanda wins" << endl;
elseif ((votesB > votesA) && (votesB > votesC)) // For if Ben wins
cout << "Ben wins" << endl;
elseif ((votesC > votesA) && (votesC > votesB)) // For if Cylcone wins
cout << "Cylcone wins" << endl;
else // If there is a tie (no one wins)
cout << "There was a tie" << endl;
cin.get(); // Similar to "system("PAUSE"), but it works across different operating systems and compilers
return 0;
}
You can get rid of that "char" variable, since it's quite useless. You could also make this program much more efficient with Arrays, but I'll try to keep things simple.
Thank you so much kitten your my new best friend! i have been having some trouble with these lol im doing network engineering but they have us take a starter programing class and i have never done it.