Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

void getscores(int test1, int test2, int test3);
int calculateave(double);
void calculateminmax(int minimum, int maximum);
void display(int test1, int test2, int test3, int minimum, int maximum, double average);

int main()
{
	int test1, test2, test3, minimum, maximum;
	double average;

	getscores(test1, test2, test3);
	calculateave(average);
	calculateminmax(minimum, maximum);
	display(test1, test2, test3, minimum, maximum, average);

	system("pause");
	return 0;
}
void getscores(int test1, int test2, int test3)
	{
		
		cout << "Enter the first test score  : ";
		cin >> test1;
		cout << "Enter the second test score : ";
		cin >> test2;
		cout << "Enter the third test score : ";
		cin >> test3;
		
			}

int calculateave(int test1, int test2, int test3)
{
	double average;

	average = (test1 + test2 + test3) / 3.0;

	return average;
	}

void calculateminmax(int test1, int test2, int test3, int minimum, int maximum)
{
	
	if (test1 <= test2  && test1 <= test3)
		minimum = test1;
	else if (test2 <= test1 && test2 <= test3)
		minimum = test2;
	else
		minimum = test3;

	if (test1 >= test2  && test1 >= test3)
		maximum = test1;
	else if (test2 >= test1 && test2 >= test3)
		maximum = test2;
	else
		maximum = test3;

}
void display(int test1, int test2, int test3, int minimum, int maximum, double average)
{
	cout << endl << "Results ..." << endl;
	cout << "The test scores are " << test1 << " and " << test2 << " and "
		<< test3 << endl;
	cout << "The average of the test scores is " << average << endl;
	cout << "The minimum test score is " << minimum << endl
		<< "The maximum test score is " << maximum << endl;

	
}
Posted
Updated 20-Jan-14 13:40pm
v2
Comments
Mohibur Rashid 20-Jan-14 19:58pm    
What does your compiler say? Learn to read your compiler messages
H.Brydon 20-Jan-14 22:25pm    
Ummm ... F5?

1 solution

We could just tell you, but then what would you learn?

There are a couple skills you need to develop, and I'm guessing are the point of the exercise your instructor gave you.

The first is to understand your compiler errors. Admittedly C++ has some of the most obscure messages, but the key is to try to solve them in order, typically one problem causes many errors that look unrelated.

The second is to be able to understand the syntax of the language. The error is pretty apparent if you just read through the code and make sure that everything matches up. Knowing what is wrong just by looking at it is something you need to develop so that you can recognize errors as you type them so you don't write 5000 lines of code only to realize you have a ton of simple syntax errors when you compile.

Its hard now but will come as second nature as you write code. A good developer knows almost immediately when they've typed something wrong, and reading code with errors is like nails on a chalkboard :)
 
Share this answer
 
Comments
H.Brydon 21-Jan-14 9:21am    
Ewwww for the chalkboard statement!
+5 for the great answer... :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900