Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The program will: Read monthly sales into a dynamically allocated array Input th

ID: 3759395 • Letter: T

Question

The program will:

Read monthly sales into a dynamically allocated array

Input the size of the array from the user

Call a function (called yearTotal) that will find the yearly sum (the sum of all the sales). This function should NOT return any values – it is a VOID function. So, the sum should be passed to the function as a reference variable.

Print the yearly sum in the main function.

Call another function (called yearAverage) that will find the average.

Print the average in the main function.

Sample Output:

Please input the number of monthly sales to be input :

4

Please input the sales for month 1:

1290.89

Please input the sales for month 2:

905.95

Please input the sales for month 3:

1567.98

Please input the sales for month 4:

994.83

The total sales for the year is $ 4759.65

The average monthly sale is $1189.91

Explanation / Answer

#include <iostream>
using namespace std;
float sum(float[], int);
float average(int, float);
int main()
{
int size;
int count;
float *sales;
float userInfo;
cout << "Please enter size you want the array to be ";
cin >> size;
sales = new float[size];
for (count = 0; count < size; count++)
{
cout << "Please enter information for array position" << count << endl;
cin >> userInfo;
sales[count] = userInfo;
}
float sum(int sales[], int size);
cout << "The sum of the Figures you entered is " << sum << endl;
float average (int size, float sum);
cout << "The average of the figures you entered is " << average << endl;
return 0;
}
float sum(float sales[], int size)
{
float sum;
float holder;
int count;
for (count = 0; count < size; count++)
holder += sales[count];
sum = holder;
return sum;
}
float average(int size, int sum)
{
int average;
average = sum / size;
return average
}