Hi
Any reason why my votes aren't adding up once the program has run?
#include <iostream>
using namespace std;
int main ( )
{
const int NR_SESSIONS = 3;
int nrAttend;
int votesForS, votesForR, votesForO;
char vote;
// Initialise totals
votesForS = 0;
votesForR = 0;
votesForO = 0;
// Loop over sessions
for (int i = 1; i <= NR_SESSIONS; i++)
{
cout << "SESSION " << i << endl;
cout << "How may pupils attended this session? " << endl;
cin >> nrAttend;
cout << endl;
// Loop over attendants
cout << "Vote 'S' for Scarlett, 'R' for Rhett and 'O' for any other character! " << endl << endl;
cout << "Which character would you like to vote for? " << endl;
cin >> vote;
for (int j = 1; j < nrAttend; j++)
{
switch (vote)
{
case 'S':
votesForS++;
break;
case 'R':
votesForR++;
break;
default:
votesForO++;
}
cout << "Next: For whom do you vote? ";
cin >> vote;
cout << endl;
}
}
// Displays results
cout << endl << endl;
cout << "Votes for Scarlet: " << votesForS << endl;
cout << "Votes for Rhett: " << votesForR << endl;
cout << "Votes for Other: " << votesForO << endl;
return 0;
}