This homework assignment is due in 2 hours and I'm screwed. PLEASE HELP

I'm working on code for a class i am currently taking. The assignment asks to
"write a C++ program that reads in an unknown number of test scores from the console (up to but not exceeding 100), and stores the values in an array.
Include in the program functions that compute and return the maximum test score, the minimum test score, the midrange of the test scores and the average (mean) of the test scores when called.
Call all functions as needed to produce a console output that includes all individual test scores separated by tabs, the max score, the min score, the midrange of the scores, and the average score."
Im having a really hard time understanding how the functions work. How do i create a function for max, min, average and median?
Then, how do i implement them in my main?
attached below is my code so far (not very good at this stuff yet)
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
  #include <iostream>
using namespace std;

int count=0;
int input;
int testScores [100]={input}; 
int high;
int low;
int min;
int max; 
int avg;
int maxVal; 

int main ()
{
	int count=0;
	cout << " Enter first test score. Enter -1 to stop. " << endl;
	cin >> input;

	while (input != -1)
	{
		testScores [count]= input; 
		count++; 
		cout << " Enter next test score. Enter -1 to stop.\t " << endl;
		cin >> input; 
	} 

	int maxval (int maximum);
		
	cout << " The maximum value is: " << maxVal << endl;
	
	cout << " The average is: : " << high << endl;
return 0;
}

int maxValue (int maximum)
{
	maxVal=0; 
	int max [100] ;

	for ( maxVal = 0; maxVal < max[100]; maxVal++)
	{
		if (max[100]>maxVal) max[100]=maxVal; 
		{
			return maxVal;
		}
	}


}




This will help you:

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

#include "iostream"
#include "conio.h"

using namespace std;

int MaxCal(int* ,int count);
int MinCal(int* ,int count);
int AvgCal(int* ,int count);

int main()
{	

	int input;
	int testScores [100];
	int count=0;

	cout << " Enter first test score. Enter -1 to stop. " << endl;
	cin >> input;

	while (input != -1)
	{
		testScores [count]= input; 
		count++; 
		cout << " Enter next test score. Enter -1 to stop.\t " << endl;
		cin >> input; 
	} 

	cout<<endl;

	cout<<"Enterd Test scores"<<endl<<endl;		//To display Entered scores
	for(int i=0;i<count;i++)
		cout<<testScores[i]<<endl;
	
	cout<<endl;

	cout<<"Max Score : "<<MaxCal(testScores,count)<<endl;
	cout<<"Min Score : "<<MinCal(testScores,count)<<endl;
	cout<<"Avg Score : "<<AvgCal(testScores,count)<<endl;
	getch();
	return 0;
}

int MaxCal(int* testArray, int count)			//To calculate Max Score
{
	int max = testArray[0];
	for(int i=1;i<count;i++)
	{
		

		if(max<testArray[i])
			max = testArray[i];

		
	}
	return max;
}

int MinCal(int* testArray, int count)			//To calculate Min Score
{
	int min = testArray[0];
	for(int i=1;i<count;i++)
	{
		

		if(min>testArray[i])
			min = testArray[i];

		
	}
	return min;
}

int AvgCal(int* testArray, int count)			//To calculate Avg Score
{
	int avg=0;
	for(int i=0;i<count;i++)
	{
		avg += testArray[i]; 
	}

	avg = avg/count;
	
	return avg;
}
Last edited on
like above you also can write code for "median".
try it by yourself.
If any issue let us know.
Topic archived. No new replies allowed.