```
//Compiler used: Visual Studio C++ Express Edition
#include <iostream>
using namespace std;
//Display the title then when the user presses 'ENTER' display
//each report accordingly.
void displayPresent();
double findMax(double[], int);
double findMin(double[], int);
double calcAvg(double[]);
int SIZE = 20;
int SIZE2 = 8;
int main()
{
double max;
double min;
double avg;
double stock1[] = {34.25,40.50,36.50,40.00,
30.25,30.25,35.50,36.00,
34.25,37.00,34.00,35.00,
36.25,34.25,40.50,41.50,
41.50,40.00,36.50,34.50};
double stock2[] = {40.25,38.50,34.50,33.50,
30.50,29.75,37.50,36.00,
34.75,38.00,34.25,37.00,
34.25,37.50,34.50,38.50,
37.50,37.25,38.25,37.50};
double stock3[] = {100.41, 90.45, 99.30, 102.99,
98.54, 95.30, 92.32, 110.88};
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
displayPresent();
//Report 1
//to output the min and max of arrays stock1, and stock2.
cout << "\n Press Enter to continue..." <<endl;
cin.ignore();
max = findMax(stock1, SIZE);
cout << max;
min = findMin(stock1, SIZE);
cout << min;
max = findMax(stock2, SIZE);
cout << max;
min = findMin(stock2, SIZE);
cout << min;
//Report 2
//to output the average of arrays stock1 and stock2 and the number of days(integers) that exceed the average.
cout << "\n Press Enter to continue..." <<endl;
cin.ignore();
avg = calcAvg(stock1);
cout << avg;
avg = calcAvg(stock2);
cout << "\n Press Enter to continue..." <<endl;
cin.ignore();
//Report 3
//to ouput the max of array stock3 and the average.
max = findMax(stock3, SIZE);
cout << max;
avg = calcAvg(stock3);
return 0;
}
double findMax(double[], int)
{
int i;
double max1;
double max2;
double max3;
double stock1[] = {34.25,40.50,36.50,40.00,
30.25,30.25,35.50,36.00,
34.25,37.00,34.00,35.00,
36.25,34.25,40.50,41.50,
41.50,40.00,36.50,34.50};
double stock2[] = {40.25,38.50,34.50,33.50,
30.50,29.75,37.50,36.00,
34.75,38.00,34.25,37.00,
34.25,37.50,34.50,38.50,
37.50,37.25,38.25,37.50};
double stock3[] = {100.41, 90.45, 99.30, 102.99,
98.54, 95.30, 92.32, 110.88};
max1 = stock1[0];
max2 = stock2[0];
max3 = stock3[0];
for(i = 0; i < SIZE; i++)
{
if(stock1[i] > max1)
max1 = stock1[i];
if(stock2[i] > max2)
max2 = stock2[i];
}
//cout << " The maximum number in stock1 = " << max1 <<endl;
//cout << " The maximum number in stock2 = " << max2 <<endl;
for(i = 0; i < SIZE; i++)
{
if(stock3[i] > max3)
max3 = stock3[i];
}
//cout << " The maximum number in stock3 = " << max3 <<endl;
return 0;
}
double findMin(double[], int)
{
int i = 0;
double min1;
double min2;
double min3;
double stock1[] = {34.25,40.50,36.50,40.00,
30.25,30.25,35.50,36.00,
34.25,37.00,34.00,35.00,
36.25,34.25,40.50,41.50,
41.50,40.00,36.50,34.50};
double stock2[] = {40.25,38.50,34.50,33.50,
30.50,29.75,37.50,36.00,
34.75,38.00,34.25,37.00,
34.25,37.50,34.50,38.50,
37.50,37.25,38.25,37.50};
double stock3[] = {100.41, 90.45, 99.30, 102.99,
98.54, 95.30, 92.32, 110.88};
min1 = stock1[0];
min2 = stock2[0];
min3 = stock3[0];
for(i = 0; i < SIZE ; i++)
{
if(stock1[i] < min1)
min1 = stock1[i];
if(stock2[i] < min2)
min2 = stock2[i];
}
for(i = 0; i < SIZE2 ; i++)
{
if(stock3[i] < min3)
min3 = stock3[i];
}
// cout << " The minimum number in stock1 = " << min1 <<endl;
//cout << " The minimum number in stock2 = " << min2 <<endl;
// cout << " The minimum number in stock3 = " << min3 <<endl;
return 0;
}
double calcAvg(double[])
{
int i = 0;
int j = 0;
double sumStock1 = 0;
double sumStock2 = 0;
double sumStock3 = 0;
int numofdaysover = 0;
double stock1[] = {34.25,40.50,36.50,40.00,
30.25,30.25,35.50,36.00,
34.25,37.00,34.00,35.00,
36.25,34.25,40.50,41.50,
41.50,40.00,36.50,34.50};
double stock2[] = {40.25,38.50,34.50,33.50,
30.50,29.75,37.50,36.00,
34.75,38.00,34.25,37.00,
34.25,37.50,34.50,38.50,
37.50,37.25,38.25,37.50};
double stock3[] = {100.41, 90.45, 99.30, 102.99,
98.54, 95.30, 92.32, 110.88};
for(int i = 0 ; i < SIZE ; i++)
{
sumStock1 += stock1[i];
sumStock2 += stock2[i];
}
for(int i = 0; i < SIZE2 ; i++)
{
sumStock3 += stock3[i];
}
for(int j = 0; j < SIZE; j++)
{
if((sumStock1/SIZE)< stock1[j])
numofdaysover++;
}
cout << " The average of stock1 = " << sumStock1/SIZE << " # of days exceeded = " << numofdaysover <<endl;
for(int j = 0; j < SIZE; j++)
{
if((sumStock2/SIZE)< stock2[j])
numofdaysover++;
}
cout << " The average of stock2 = " << sumStock2/SIZE << " # of days exceeded = " << numofdaysover <<endl;
for(int j = 0; j < SIZE; j++)
{
if((sumStock2/SIZE)< stock3[j])
numofdaysover++;
}
cout << " The average of stock3 = " << sumStock3/SIZE << " # of days exceeded = " << numofdaysover <<endl;
return 0;
}
void displayPresent()
{
cout << "\n The Stock Problem" << endl << endl;
}
```