MY CODE >> Star Search
/*  Tommy Martin

    This program will be used to calculate the average of five judges scores.
	The highest and lowest scores must be dropped before getting the average.

    StarSearch.cpp
*/

#include<iostream>
#include<iomanip>

using namespace std;

// Function Prototype
void intro();
void getJudgeData(double &);
void validJudge (double &);
void calcScore(double, double, double, double, double);
double findLowest(double, double, double, double, double);
double findHighest(double, double, double, double, double);

int main()
{

	// declare initial valiables
	double j1 = 0, j2 = 0, j3 = 0, j4 = 0, j5 = 0;


	// call functions
	intro();

	getJudgeData(j1);
	getJudgeData(j2);
	getJudgeData(j3);
	getJudgeData(j4);
	getJudgeData(j5);

	calcScore(j1, j2, j3, j4, j5);

    return 0;

	system("pause");
}

//function used to display instruction for the user
void intro () {

	cout << "Please enter each judge's score one at a time.\n"
			"The score must be between 0 and 10.\n\n";

}

// fucntion used to get teh judges scores
void getJudgeData(double & judgeScore) {

	cout << "Please enter the judges score  - "; cin >> judgeScore; cout << endl;
	validJudge (judgeScore);  // call to function to valid the score entered

}

// function used to validate judges input is between 0 and 10
void validJudge (double & judgeScore) {


	// Check judges input
	while ( !(judgeScore >= 0 && judgeScore <= 10) ) {

		cout << "Please enter a score between 0 and 10 - "; cin >> judgeScore; cout << endl;

	}

}

// this function calculates and diplays the judges scores
void calcScore(double j1, double j2, double j3, double j4, double j5) {

	// declare variables to send to high and low score functions
	double highScore = 0, lowScore = 0, average = 0;

	// call function to calculate high, low, and average scores
	highScore = findLowest(j1, j2, j3, j4, j5);
	lowScore = findHighest(j1, j2, j3, j4, j5);

	average = (j1 + j2 + j3 + j4 + j5 - highScore - lowScore) / 3;

	// output the high, low, and average scores
	cout << "\n--------------------\n";
	cout << "High Score:    " << fixed << setprecision(2) << highScore << endl;
	cout << "Low Score:     " << fixed << setprecision(2) << lowScore << endl;
	cout << "Average Score: " << fixed << setprecision(2) << average << endl;
	cout << "\n--------------------\n\n";

}

//function used to find the lowest number
double findLowest(double j1, double j2, double j3, double j4, double j5) {

	// declare a variable to hold lowest number
	double lowestScore = j1;

	// if statements used to determine the lowest number
	// single if statements used becuase each statement needs to run once
	if (lowestScore < j2)
		lowestScore = j2;

	if (lowestScore < j3)
		lowestScore = j3;

	if (lowestScore < j4)
		lowestScore = j4;

	if (lowestScore < j5)
		lowestScore = j5;

	// returns the value of lowestScore to whoever calls the function
	return lowestScore;

}

// function to find the highest number
double findHighest(double j1, double j2, double j3, double j4, double j5) {

	// declare a variable to hold lowest number
	double highestScore = j1;

	// if statements used to determine the lowest number
	// single if statements used becuase each statement needs to run once
	if (highestScore > j2)
		highestScore = j2;

	if (highestScore > j3)
		highestScore = j3;

	if (highestScore > j4)
		highestScore = j4;

	if (highestScore > j5)
		highestScore = j5;

	// returns the value of higestScore to whoever calls the function
	return highestScore;

}