This program is incomplete as I am having difficulty creating the function that needs to find the number of perfect scores entered by the user. I have everything but the function complete ,here is my code:
Code:
// Write a modular program that accepts at least 10 integer
// test scores from the user and stores them in an array.
// The main should display how many perfect scores were
// entered (i.e., scores of 100), using a value-returning countPerfect
// function to help it.
// Input validation: Do not accept scores less than 0 or greater than 100.
#include <iostream>
using namespace std;
int countPerfect(int intArray[], int); // Function prototype
int main()
{
const int TEST_SCORES = 10;
int testScores[TEST_SCORES], // Holds test scores for 10 tests
perfect;
cout << "Please enter " << TEST_SCORES << " test scores\n";
cout << endl;
for(int index = 0; index < TEST_SCORES; index ++)
{
cout << "Test " << (index + 1) << ": ";
cin >> testScores[index];
cout << endl;
while((testScores[index] < 0) || (testScores[index] > 100))
{
cout << "Invalid score, please enter a number greater than 0 or less than 100 \n";
cin >> testScores[index];
}
}
cout << "Here are the scores you entered\n";
cout << endl;
for(int index = 0; index < TEST_SCORES; index ++)
{
cout << "Test " << (index + 1) << " : " << testScores[index] << endl;
}
cout << endl;
cout << "The total number of perfect scores was: \n";
countPerfect(testScores, TEST_SCORES);
cout << "There were " << perfect << " scores of 100.\n";
cout << endl;
system("pause");
return 0;
}