//program is to read up to 10 donation values into an array of double.
//The program should terminate input on non-numeric input. It should report the
//average of numbers and also report how many numbers in the array are larger
//than the average. Using isalpha function closes my command window beofer any results is display. I put the isalpha function in my comment field below illustrating how I wanted to use it.
CODE
#include<iostream>
#include<cctype>
const int ArSize =10;
int main(int argc, char **argv)
{
using namespace std;
double donations[ArSize];
double p, average = 0, total;
char q;
int i = 0, count =0, larger_than_average =0;
cin >> p;
// want to use isalpha here
while (i != ArSize) // using isalpha function like this while (!= isalpha(p))
{
donations[i] = p;
total += donations[i];
i++;
cin >> p;
count += 1; // keeping account of how many inputs
average = ( total /count);
}
for (i=0; i< ArSize; i++) // reading output of array and using loop in helping to determine larger than average
{
if( donations[i] > average)
larger_than_average += 1; // keeping account of numbers larger than average
cout << donations[i]<< endl;}
cout << "Program has been terminated by user"<<endl;
cout << "average " << average <<endl;
cout << " numbers in the array larger than average " << larger_than_average <<endl;
system ("pause");
return 0;
}