College Assignment Help

Hi all,
I have a college assignment which I feel I may need some pointers on as things are not running smoothly. Any help would be appreciated. Here is what the assignment asks of me:

Write a program to store an input list of ten integers in an array and then output all ten element values on one line. Below that output the range of values used, the average(or mean) value of the ten numbers and a table with the values that are greater than that average.

1. Use at least 7 or more functions in your program. You can decide which functions you want to write(possible functions might to input all the data, calculate smallest value in array, calculate largest value in the array, calculate average, output the list of values above the average, output program ID, or output ALL the output for the program). Be sure to pass all parameter values correctly as pass by Value or pass by Reference.

2. Use the formatting manipulators that you have studied to get your output to look like the example below. Do not sort the array of elements but use the algorithm that is discussed in the textbook to find the smallest and the largest values in the data set entered. Those two values will be the “range” needed for the output.

I have "created" functions that give the highest value, the lowest value, the range of values, input, output, average, and some data output.

Here is the mess that I have so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
  #include <iostream>
using namespace std;

double inputArray(double NUM[]);
double outputArray(double NUM[]);
double highNum(double NUM[], int numCount);
double lowNum(double NUM[], int numCount);
double findAverage(double NUM[], int numCount);
double range(int lowest, int highest);
double valuesAbove(double NUM[], int numCount, double average);

void userID();


int main()
{
	const int numCount = 10;
	double NUM[numCount], average;
	int lowest, highest;
	
	cout << "Enter numbers:\n" ;-
	inputArray(NUM);
	
	highNum(NUM, numCount);
	cout << "The highest value is: " << highest << endl;
	
    lowNum(NUM, numCount);
    cout << "The lowest value is: " << lowest << endl;
   
    range(lowest, highest);
   
    findAverage(NUM, numCount);
    cout << "Average of the ten values is: " << average << endl;
	
	valuesAbove(NUM, numCount, average);
	
	userID();
}

double inputArray(double NUM[])
{
	
	cin >> NUM[0];
	cin >> NUM[1];
	cin >> NUM[2];
	cin >> NUM[3];
	cin >> NUM[4];
	cin >> NUM[5];
	cin >> NUM[6];
	cin >> NUM[7];
	cin >> NUM[8];
	cin >> NUM[9];
	outputArray(NUM);
}

double outputArray(double NUM[])
{
	cout << "\nValues in data set" << endl;
	cout << NUM[0] << " " ;
    cout << NUM[1] << " " ;
    cout << NUM[2] << " " ;
    cout << NUM[3] << " " ;
    cout << NUM[4] << " " ;
    cout << NUM[5] << " " ;
    cout << NUM[6] << " " ;
    cout << NUM[7] << " " ;
    cout << NUM[8] << " " ;
    cout << NUM[9] << endl;
}

double highNum(double NUM[], int numCount)
{
	int count;
	int highest;
	
	highest = NUM[0];
	for (count = 1; count < numCount; count++)
	{
		if (NUM[count] > highest)
		highest = NUM[count];
	    return highest;
	}
}

double lowNum(double NUM[], int numCount)
{
	int count;
	int lowest;
	
	lowest = NUM[0];
	for (count = 1; count < numCount; count++)
	{
		if (NUM[count] < lowest)
		lowest = NUM[count];
	    return lowest;
	}
}

double findAverage(double NUM[], int numCount)
{
	double total = 0;
	double average;
	for (int count = 0; count < numCount; count++)
		total += NUM[count];
	average = total / numCount;
	return average;
} //find average

double range(int lowest, int highest)
{
	cout << "Values used range from: " << lowest << " to " << highest << endl;
}

double valuesAbove(double NUM[], int numCount, double average)
{
	int ct;
	for (ct = 0; ct < numCount; ct += 1)
	{
		if (NUM[] > average)
		{
		cout << "Values above the average" << endl;
		cout << NUM[];
    	}
    }
}
void userID()
{
	cout << "Lab7" << endl;
}
1.- why you dont use a for loop for the input and output:


double inputArray(double NUM[])
{
for(int a=0;a<10;a++){
cout<<"Input the number "<<a+1<<"\n";
cin >> NUM[a];}
outputArray(NUM);
return 0; }

void outputArray(double NUM[])
{
cout << "\nValues in data set " << endl;
for(int a=0;a<10;a++){cout<<NUM[a]<<" ";}

}
2.- The return value in highest and lowest most be out of the for loop:

for (count = 1; count < numCount; count++)
{
if (NUM[count] > highest)
highest = NUM[count];
}
return highest;

3.- You must to remember that the highest and lowest inner the function are not the same in the main so why you dont use te return value of highest in main or use equal to initializing higher:

example 1:

cout << "The highest value is: " << highNum(NUM, numCount) << endl;

example 2:

higher=highNum(NUM, numCount);
cout << "The highest value is: " << higher << endl;

4.- Why you dont use double in range:

void range(int lowest, int highest)?????

5.- Remember two thing if you dont use void you must to return a value in a function and if you repear the loop and put a cut it will apper to to much times:

void valuesAbove(double NUM[], int numCount, double average)
{
int ct;
cout << "Values above the average " << endl;
for (ct = 0; ct < numCount; ct += 1)
{
if (NUM[ct] > average)
{
cout << NUM[ct]<<" ";
}
}
You are doing a excellent job just need to watch for the little things
Edevan,
Thank you so much for your help. This has been a big help. You are very kind. I do appreciate it
Topic archived. No new replies allowed.