Hi there all,
Could anybody please help me, as to why my program is not adding the right quantity's?
// Question 2a
#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 voting stations
for (int i = 1; i <= NR_SESSIONS; i++)
{
cout << "SESSIONS " << i << endl;
cout << "How may pupils attended this session? " << endl;
cin >> nrAttend;
// Loop over attendants
cout << "First: Which character would you like to vote for? ";
cin >> vote;
for (int i = 2; i <= nrAttend; i++)
switch (vote)
{
case 'S':
votesForS++; break;
case 'R':
votesForR++; break;
default:
votesForO++;
cout << "Next: For whom do you vote? ";
cin >> vote;
}
}
// 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;
}