View Single Post
Old 09-24-2003, 08:47 AM   #3 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
I have no idea what your current skillset is, nor do I know what the requirements are, but here is something that works, without comprimising your style too much (I hope).

Code:
#include <iostream.h>

void getValues();
void findLowest();
void calcAverage();

int a,b,c,d,e,lowest; //Will hold user input and calculated lowest input.

int main()
{
	getValues();
	findLowest();
	calcAverage();
	return 0;
}

void getValues()
{	
	cout << "Please enter 5 test scores (0-100): ";
	cin >> a >> b >> c >> d >> e;
	if (a>100 || a<0 || b>100 || b<0 || c>100 || c<0 || d>100 || d<0 || e>100 || e<0)
	{
		cout<<endl<<"WARNING, INVALID DATA:"<<endl<<
			"Entered data was NOT between 0 and 100, scores below are INVALID!"<<endl<<endl;
	}
}

void findLowest()
{
	if (a<b && a<c && a<d && a<e){
		lowest=a;
	}

	if (b<a && b<c && b<d && b<e){
		lowest=b;
	}

	if (c<a && c<b && c<d && c<e){
		lowest=c;
	}

	if (d<b && d<c && d<a && d<e){
		lowest=d;
	}
	
	if (e<b && e<c && e<d && e<a){
		lowest=e;
	}
	
	cout << "The Lowest Score Was: " << lowest << endl;
}

void calcAverage()
{
	int avg;
	avg = ((a+b+c+d+e)-lowest)/4;
	cout << "The Average score was: " << avg << endl;
}
__________________
Valmont is offline   Reply With Quote