Thread: Help with numbers

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    13

    Unhappy Help with numbers

    I am trying to work out the average of 15 gymnasts by taking away the maximum and minimum of their scores from their TOTAL scores and then dividing this by the number of judges (5). I keep getting the wrong output though and it seems that there is an error with numbers somewhere. I have attached the file where the data is being read from.

    float CalculateGymnastScore (float JudgesScores[], int Judges)
    {
    float Sum, Max, Min, FinalScore;
    int i;
    int Temp;
    Sum=0;

    Max=GetMaxScore(JudgesScores, NO_OF_JUDGES);
    Min=GetMinScore(JudgesScores, NO_OF_JUDGES);
    for(i=0;i<NO_OF_JUDGES;i++)
    Sum+=JudgesScores[i];
    Temp=Max+Min;
    FinalScore=Sum-Temp/Judges;
    return(FinalScore);
    }

    float GetMaxScore(float JudgesScores[], int Judges)
    {
    int Counter;
    int Max;
    Max=0;
    for(Counter=0;Counter<Judges;Counter++)
    {
    if(JudgesScores[Counter]>Max)
    Max=JudgesScores[Counter];
    }
    return(Max);
    }

    float GetMinScore(float JudgesScores[], int Judges)
    {
    int Counter;
    int Min;
    Min=100;
    for(Counter=0;Counter<NO_OF_JUDGES;Counter++)
    {
    if(JudgesScores[Counter]<Min);
    Min=JudgesScores[Counter];
    }
    return(Min);
    }

    ***THANKS FOR YOUR HELP***

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    13

    Unhappy

    Here's the file where the numbers are being read from!

  3. #3
    Registered User alex's Avatar
    Join Date
    Sep 2001
    Posts
    132
    Hi!

    I think you meant
    FinalScore=(Sum-Temp)/Judges;
    or maybe
    FinalScore=(Sum-Temp)/(Judges-2);

    alex

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  2. Adding Line numbers in Word
    By Mister C in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 06-24-2004, 08:45 PM
  3. Replies: 4
    Last Post: 03-03-2003, 03:52 PM
  4. the definition of a mathematical "average" or "mean"
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 12-03-2002, 11:15 AM
  5. A (complex) question on numbers
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 02-03-2002, 06:38 PM