cant get this work new to C++ for class any ideas great

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



// Lab07 problem 1 By David Warner 2/19/11

#include <iostream>

using namespace std;

int main( )
{
double votes = 0.0;
char = ' ';

cout << "Enter votes for Amanda" << endl;
cin >> votes;
cout << "Enter votes for Ben" << endl;
cin >> votes;
cout << "Enter votes for Cyclone" << endl;
cin >> votes;


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.)

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
#include <iostream>
using namespace 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;
    else if ((votesB > votesA) && (votesB > votesC))    // For if Ben wins
        cout << "Ben wins" << endl;
    else if ((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.
Last edited on
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.
I know this is off topic.

But Network Engineering? What do you do with a degree in that?
I think it's got something to do with like engineering networks or something like that.

Helpful link: http://tinyurl.com/5wmtvmn
Topic archived. No new replies allowed.