Down to the wire...need help within the next few hours

Status
Not open for further replies.

deena

Solid State Member
Messages
7
I have a project due for a class I am taking and am just not getting it! Unfortunately, no one has been available in the labs at the college to help me out, so I am hoping someone here can. The exercise is:

A particular talen cometition has 5 judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 8.3 are allowed. A performers final score is determined by dropping the highest and lowest scores received, then averaging the 3 remaining scores. Write a program that uses this method to calculate a contestant's score. It should include the following functions:

* void getJudgeData() should ask the user for a judge's score, store it in a reference perameter variable, and validate it. This function should be called by main once for each of the 5 judges.

* void calcScore() should calculate and display the average of the 3 scores that reamin after dropping the highest and lowest scores. This function should be called just once by main, and should be passed the 5 scores.

The last two functions should be called by calcScore, who uses the returned information to determine which of the scores to drop.

* int findLowest() should find and return the lowest of the 5 scores passed to it
* int fineHighest() should find and return the lowest of the 5 scores passed to it.

Input validation, don't accept judges scores lower than 0 or higher than 10.


Here is what I have so far.......

// This program gives the average judge's score while dropping
// the lowest and highest score


#include <iostream>
using namespace std;

double score;
int judge;


int main()
{

void getJudgeData(int judge)
{

cout <<"Please enter Judge " << judge <<"'s score:\n";
cin >> score;

while (score < 0 || score > 10)
{
cout << "Score must be between 0 and 10. Please enter a score in that range:\n";
cin >> score;

}

}
{
getJudgeData(1);
getJudgeData(2);
getJudgeData(3);
getJudgeData(4);
getJudgeData(5);
}
{
int findLowest(double &refVar);
}


{
int findHighest(double &refVar);
}
{

void calcScore();
}



cout << "more here";

return 0;
}
 
Looks like your input method works fine. You nee dhelp with the findLowest and findHighest methods.

First, you're going to want to read your input into an array.

Code:
for (i=0; i<5; i++)
  scores[i] = getJudgeData(i+1);

For findLowest/highest all you need to do is this (I'm posting in pseudocode)



Code:
lowest = 11
highest = -1
for (i=0; i < 5; i++){
  lowest = min(lowest, scores[i])
  highest = max(highest, scores[i])
}

For the calcScores, just add up all the scores and subtract the lowest and highest.

Code:
total = 0
for (i=0; i < 5; i++)
  total = total + scores[i]

score = (total - highest - lowest) / 3
 
Thank you so much! I couldn't figure out the whole dropping the high and low score thing. It didn't occur to me to subtract them! I just don't think programming yet! This gets be back up and working on it.....I may just get this in on time yet! :)

I feel like I am such an idiot..... it takes so long for this to click in my little pea brain!
 
I think I am stuck on the whole reference parameter variable.... can anyone explain how that works?
 
Am I making any progress at all or have I gone so far off the path I will never get it????

***********************************

#include <iostream>
using namespace std;

void getJudgeData(double &, int );
void calcScore(double, double, double, double, double);
double findLowest(double, double, double, double, double );
double findHighest(double, double, double, double, double );
double score;
int judge;


int main()

{

double judge1;
double judge2;
double judge3;
double judge4;
double judge5;

getJudgeData(judge1,1);
getJudgeData(judge2,2);
getJudgeData(judge3,3);
getJudgeData(judge4,4);
getJudgeData(judge5,5);

calcScore(judge1, judge2, judge3, judge4, judge5);

return 0;
}



void getJudgeData(double &score, int x)
{

cout <<"Please enter Judge " << x <<"'s score:\n";
cin >> score;

while (score < 0 || score > 10)
{
cout << "Score must be between 0 and 10. Please enter a score in that range:\n";
cin >> score;

}

}


double findLowest(double s1, double s2, double s3, double s4, double s5)
{
double lowest;



return lowest;

}



double findHighest (double s1, double s2, double s3, double s4, double s5)
{
double highest;


return highest;

{

void calcScore();

avgScore = (total - highest - lowest) / 3;
cout << "The average score is "<< aveScore << endl;

}
 
Status
Not open for further replies.
Back
Top Bottom