# Help me with a very basic math algorithm?

• May 21st, 2012, 06:17 PM
seaofFire
Help me with a very basic math algorithm?
There are 3 judges, 3 rounds and 3 judges in this diving competition.

There is also a degree of difficulty from 1 to 3.5 that multiplies with the added score

Suppose Contestant 1 would go first:

Degree of difficulty = 2
Judge 1 would give 9
Judge 2 would give 5
Judge 3 would give 1

Now the highest and lowest scores are removed max and min (don't ask why)

So the total would be 10 for Contestant1

My programs calculation is - total [0] = total [0] + ((score [0] - max [0] - min [0]) * degree);

Can you correct my formula or tell me something else is wrong?
• May 21st, 2012, 06:46 PM
Norm
Re: Help me with a very basic math algorithm?
What is in the score array?
What is in the total array when the posted line of code is executed? Why is total[0] to the right of the =?

What value does your formula compute?

Write out the equation on a piece of paper replacing the variables with their values and see if it makes sense.
• May 21st, 2012, 07:50 PM
seaofFire
Re: Help me with a very basic math algorithm?
Score array is what the three judges input. The total array is the scores added up (all 3) multiplied by the degree - the lowest and highest number.

I dont really understand what you mean why is total [0] right of line - shouldn't it always be? I'm new to programming and keep it simple.
• May 21st, 2012, 07:57 PM
Norm
Re: Help me with a very basic math algorithm?
total [0] = total [0] + ((score [0] - max [0] - min [0]) * degree);

Why is the total[0] in red where it is in the formula? What value will it have before the statement is executed?

What value is in the score[0] variable?

Write out the statement replacing the variables with their values and post it here.
• May 22nd, 2012, 08:03 PM
seaofFire
Re: Help me with a very basic math algorithm?
Total is 0,degree is 2 and score - one is 1, two is 5 and three is 9. So max would be 9 and min would be 0. That way it should be 10.

Sorry if I bolded

Maybe I should just go to the first forum - whats wrong with my code..
• May 22nd, 2012, 08:53 PM
Norm
Re: Help me with a very basic math algorithm?
Why do you use score[0] in your formula? Is that one of the three scores?
What is in the total, max and min arrays? How many elements are in the arrays? Why are those variables arrays?