// Mr. Minich
// CMPSC 101
// Ch. 10 Demo Program #3
// January 30, 2000
// Purpose - the use of parallel arrays
#include <iostream>
using namespace std;
int main()
{
int runningTotal = 0; // total of all scores
int count = 0; // position within array
int goodGames[100]; // keeps track of scores over 200
int gameScores[100]; // it is assumed that the user
// will not need to enter more
// than 100 game scores
// goodGames and gameScores are used as parallel arrays
do
{
count++; // we are not going to make use of the
// zero position of the array
cout << "Enter the score of Game " << count << " (-99 to stop): ";
cin >> gameScores[count];
if (gameScores[count] != -99)
{
runningTotal = runningTotal + gameScores[count];
}
if (gameScores[count] >= 200)
{
goodGames[count] = 1;
}
} while(gameScores[count] != -99);
// runningTotal is an accumulator.
// The user enters the sentinel value of -99 to indicate that he/she
// is finished entering game scores.
cout << "Your average score was " << runningTotal / (count - 1) << endl;
cout << "You bowled 200 or better in the following games: ";
count--;
for (int i = 0; i <= count; i++) // count was decremented above
// and now reflects the correct
// number of games.
{
if (goodGames[i] == 1)
{
cout << i << " ";
}
}
cout << endl;
return 0;
}// end of main