Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

Thread: Help me with a very basic math algorithm?

1. 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  = total  + ((score  - max  - min ) * degree);

Can you correct my formula or tell me something else is wrong?  Reply With Quote

3. 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 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.  Reply With Quote

4. The Following User Says Thank You to Norm For This Useful Post:

seaofFire (May 22nd, 2012)

5. 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  right of line - shouldn't it always be? I'm new to programming and keep it simple.  Reply With Quote

6. Re: Help me with a very basic math algorithm?

total  = total  + ((score  - max  - min ) * degree);

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

What value is in the score variable?

Write out the statement replacing the variables with their values and post it here.  Reply With Quote

7. 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..  Reply With Quote

8. Re: Help me with a very basic math algorithm?

Why do you use score 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?  Reply With Quote