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 108 109 110 111 112 113 114 115 116 117 118
|
#include <iostream>
#include <string>
using namespace std;
//Function prototypes
void record_scores();
float calculate_average_score(float, float, float, float);
float get_lowest_score(float, float, float, float);
float get_higest_score(float, float, float, float);
float remainingScores(float, float, float, float);
void show_event_highlight();
float min, max, average;
int main()
{
//Variables
float score1, score2, score3, score4, average;
//Display info to get performers name and scores
record_scores();
cin >> score1 >> score2 >> score3 >> score4; //Program will not continue past this point
while (score1 < 0 && score1 > 10
&& score2 < 0 && score2 > 10
&& score3 < 0 && score3 > 10
&& score4 < 0 && score4 > 10)
{
cout << "Please enter a valid score between 1 and 10";
}
//Calculate average score
average = calculate_average_score(score1, score2, score3, score4);
//Show details
void show_event_highlight();
}
//Get performers name and scores received by judges
void record_scores()
{
string name;
cout << "Please enter performers name: ";
getline(cin, name);
cout << " Please enter " << name << " scores, separated by a space: " << endl;
}
float calculate_average_score(float score_1, float score_2, float score_3, float score_4)
{
float average, leftover;
//Get lowest score
min = get_lowest_score(score_1, score_2, score_3, score_4);
//Get highest score
max = get_higest_score(score_1, score_2, score_3, score_4);
leftover = remainingScores(score_1, score_2, score_3, score_4); //How do I find the two remaining scores?
average = (min + max + score + score...) / 6; //This is where I am really confused. When I am able to retrieve the remaining scores, how do I implement them into my program?
return average;
}
float get_lowest_score(float entry1, float entry2, float entry3, float entry4)
{
min = entry1;
if (entry2 < entry1)
min = entry2;
if (entry3 < entry2)
min = entry3;
if (entry4 < entry3)
min = entry4;
return min;
}
float get_higest_score(float scoreOne, float scoreTwo, float scoreThree, float scoreFour)
{
max = scoreOne;
if (scoreTwo > scoreOne)
max = scoreTwo;
if (scoreThree > scoreTwo)
max = scoreThree;
if (scoreFour > scoreThree)
max = scoreFour;
return max;
}
float remainingScores(float num1, float num2, float num3, float num4)//Not sure if this is correct
{
if (num1 != min && num1 != max)
return num1 * 2;
if (num2 != min && num2 != max)
return num2 * 2;
if (num3 != min && num3 != max)
return num3 * 2;
if (num4 != min && num4 != max)
return num4 * 2;
}
void show_event_highlight()
{
cout << "The average score amongst the performer was: " << average << endl;
}
|