This assignment will require you to develop a program that reads a series of positive and negative integers from the user and loads these values into an array. The program then calculates and outputs the average of the values read. You will develop the entire program from the problem statement, including developing the pseudo code, and the test data. There is no program template. You will be required to use the supplied function for loading the data. You must submit the program design/pseudo code for your program in advance of the program submission. The pseudo code is graded separately, and the instructor must approve your pseudo code/design before you can submit the c++ code.
Inputmod Function C++ code for a function named inputmod is in this conference. You must use this function with no changes. Bring the code into your project, including all comments, but do not change it in any way. You pass this function two parameters, an array of integers, and an integer value in which the function places a count of how many values were read. The function prompts the user to enter a value (negative values are valid and accepted) and continues prompting, reading and placing values in the array until an end-of-file mark is read.
End of File The last character in every file is a special character that marks the last character in the file to the operating system. It is a real character, and on a Windows/MS DOS machine it is CTRL Z. After you have entered the last value, at the next prompt enter CTRL Z and inputmod will return.
The Program Your program will read an unknown number of integers into an array, calculate the average, and produce a report with the average. Although the number of values to be averaged is not known, and may be different each time, assume that it is less than 100. You will need to write a function to calculate the average that has a float return value. Pass it the array and the number of values in the array, and return the average. Produce a report, either in main or with another function of the results of the calculation.
You must appropriately document your code, use appropriate indentation, and use self documenting variable names. Each module must have a set of header comments that lists the name of the person who created the code (i.e., you for the functions that you write, me for the functions that I wrote that you use), the date the code was created, a section listing revisions and revision dates (which will be empty in this the initial release of your program), a description of what the module does, what the module needs as inputs, the type of the inputs, and where they come from either the key board, or passed as parameters. Finally the header comments should describe the outputs from the module. Any known invalid cases or problems should also be described. Restrictions (like the limit of 100 values) should also be placed appropriately in the header.
You are responsible for creating a set of data to fully test your program, and to submit this with your assignment.
In addition to what's need here is inputmod;
void inputmod (int values [], int &count)
/***************************************************************************
* *
* inputmod *
* *
* a general utility routine for prompting a user to enter numbers *
* into an array. The user indicates that all valuews have been *
* by entering an EOF (end of file) which is CTRL Z on an MS-DOS *
* operating system. After the user enters CTRL Z the routine *
* the data entered using outputmod *
* *
* parameters *
* values an integer array which is filled and returned *
* count a reference parameter that upon return contains *
* the number of values read *
* *
* *
***************************************************************************/
{
count = 0;
do
cout << endl <<"Enter value " << count <<
endl << "CTRL Z to stop" << endl << ">> " ;
while (cin >> values [count++]);
count--;
}
“Array, Average, Final project –pseudo code”
void inputmod (int values [], int &count)
void averagemod (float i, float nSum, int nNumber, float count)
printf outputmod (
declare nValues as constant 25
Main module
declare values [nValues] as integer
declare count as integer
count = 0
while count <= 25
call input module
end while
while count <=25
call average module
end while
while count >=25
call output module
end while
End main module
Input module (integer values [], integer count as ref)
* a general utility routine for prompting a user to enter numbers *
* into an array. The user indicates that all valuews have been *
* by entering an EOF (end of file) which is CTRL Z on an MS-DOS *
* operating system. After the user enters CTRL Z the routine *
* the data entered using outputmod *
* *
* parameters *
* values an integer array which is filled and returned *
* count a reference parameter that upon return contains *
* the number of values read *
* *
set count = 0
do
write "Enter value " count
"CTRL Z to stop" ">> "
while
input values [count++]
count--;
End input module
Average Module (count, values, averages as ref)
* calculationmod *
* *
* a general utility routine for calculating the average *
* user input into an array. *
* *
* parameters *
* values an integer array which is filled and returned *
* count a reference parameter that upon return contains *
* the number of values read *
* *
declare sum, i as float
for (i=0, i<=count, i++)
set sum += values[i]+ values[i]
set average[i] = sum/count
write "This program averages a set of numbers\n”
“Enter number to average\n”
“Enter CTRL Z to terminate input”
end for
End Average Module
Output module (count, values, average)
* outputmod *
* *
* a general utility routine for outputing the average *
* user input into an array. *
* *
* parameters *
* values an integer array which is filled and returned *
* count a reference parameter that upon return contains *
* the number of values read *
write “Input terminated.”
write “Input data:”
displayArray (values, count)
write “The average is “ average
End Output Module