help for project in intro C++ class

hi I'm a student at Penn State and am having trouble with a major project that's due in two days. Any help would be greatly GREATLY appreciated. here is the instructions copied from the writeup of the project:

Goals: Developing problem-solving skills, using loops and functions

Problem: You have been asked to write a program that will help keep score for a gymnastics competition. There are seven judges who will report a score between 0 and 10 inclusively. You will need to calculate the average score after dropping the highest and lowest score. Your program will employ use 4 functions other than main.

The first functions should be a void function that will accept two values, a score and a number of the judge, ask the user to enter the score for this judge, robustly confirm that the score is valid, then send the correct score back to main. This function will be called seven times from main (once for each judge).

Another function will determine the minimum score. This function will accept 7 score values, determine the minimum of the 7 values, and return the minimum value to the function call. This function should be called from the function to calculate the average.

Another function will determine the maximum score. This function will accept 7 score values, determine the maximum of the 7 values, and return the maximum value to the function call. This function should be called from the function to calculate the average.

The fourth function should calculate the average score for the gymnast. This function should accept 7 scores, call the function to determine the minimum score, call the function to determine the maximum score, calculate the average score without the minimum and maximum vales, and return the average. This function will be called from main.

The main function should prompt the user to enter the name of the gymnast (use a string object), call the appropriate functions and output the name of the gymnast and the average score for the gymnast.

Do not use concepts beyond Chapter 6 of your text book. Do not use any system commands. Remember that your introductory comments should describe the problem without reference to any material outside the program. Plus you should have comments that appear immediately before each function that describes the purpose, input, processing and output for that function. Upload your source code to the drop box on ANGEL.


and here is the code of what 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
/*
jake lemay
block 004
this program will keep score for a gymnastics competition
input: score, name
output: average, name
processing:
*/

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

void score();
void minimum(int);
void maximum(int);
void avg(int);

int main(int average)
{
	string name;
	cout << "please enter the name of the gymnast: ";
	getline(cin, name);

	cout << name << " recieved an average score of " << average << ".";
}


void score()
{
	int score;
	int count;

	for (count = 1; count < 7; count++)
	{

		cout << "please enter the score given by the judge " << count << ": ";
		cin >> score;
		while (score > 10 && score < 0)
		{
			cout << "please enter a score between 0 and 10: ";
			cin >> score;
		}

		minimum(score);
	}
	
}

void minimum(int score)
{
	int min;
	int count;

	for (count = 1; count < 7; count++)
	{
		if (score1 > score2)
		{
			score2 = min;
		}
		else if (score2 > score1)
		{
			score1 = min;
		}
		avg(min);
	}

	


}

void maximum(int score)
{
	int max;
	int count;

	for (count = 1; count < 7; count++)
	{
		if (score1 > score2)
		{
			score1 = max;
		}
		else if (score2 > score1)
		{
			score2 = max;
		}
		avg(max);
	}

}

void avg(int min, int max)
{
	int average;
	int min;
	int max;

	average = (max + min) / 2;

	main(average);

}

i know I probably have this code completely wrong, but I'm still learning and I'm a little behind in my studies. also I added score1 and score2 to fill in so the if and else if functions weren't empty.
robustly confirm that the score is valid, then send the correct score back to main.


I dont understand. Its a void function, it cant return anything to main.

Also. main(average); Nope.

I'll edit this with time.

Edit 1: int main(int average) NOPE. Remove that. You dont decide what parameters main takes. Leave it at int main()

Edit 2: Okay I think Im getting the hang of the instructions. You want to call the
void avg(int min, int max) from main.

You want the void avg(int min, int max) to call the min/max functions, so It can apparently determine which is the min, which is the max, and then not include those in the average counting.
Last edited on
Thank you very much Tarik. I look forward to your response. I will continue to study as hard as I can in hopes of maybe eventually understanding. :3
sure i can add you! the thing is I have to go to work in two hours. I'm available 10 am to 3 pm eastern time tomorrow though if that's ok.
er have you add me i mean
I would do it this way.

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
void populateArray(int score[], int judge);
int getMin(int score[], int arraySize);
int getMax(int score[], int arraySize);
double getAvg(int score[], int arraySize)
{
	int min = getMin(score, arraySize);
	int max = getMax(score, arraySize);
	double sum = 0.0;
	//loop arraySize times
	{
		//update sum
	}
	sum = sum - min - max;
	return sum / (arraySize - 2);
}

int main()
{
	const int arraySize = 7;
	int score[arraySize] = {0};
	double avg;
	std::string name;
	
	//prompt for name
	
	//loop arraySize times
	{
		//call populateArray
	}
	
	avg = getAvg(score, arraySize);
	
	std::cout << "Name:  " << name << std::endl;
	std::cout << "Score: " << avg << std::endl;
	
	return 0;
}
Last edited on
Topic archived. No new replies allowed.