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


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Help me with a very basic math algorithm?

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default 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?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

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

    seaofFire (May 22nd, 2012)

  4. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default 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.

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #5
    Junior Member
    Join Date
    Apr 2012
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default 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..

  7. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default 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?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Basic Math Expression Java Problem
    By andyluvskrissy in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 15th, 2011, 03:22 AM
  2. For the Math Majors
    By mszyndlar in forum Java Theory & Questions
    Replies: 0
    Last Post: October 18th, 2011, 04:40 PM
  3. Basic Java Sorting Algorithm (Selection/Insertion) help
    By Arte7 in forum Algorithms & Recursion
    Replies: 5
    Last Post: August 22nd, 2011, 01:38 PM
  4. Confusion with Math.toDegrees() and Math.toRadians(). Please help.
    By marksquall in forum Java Theory & Questions
    Replies: 3
    Last Post: June 23rd, 2011, 01:28 AM
  5. Basic Math Expression Java Problem
    By andyluvskrissy in forum Object Oriented Programming
    Replies: 3
    Last Post: September 30th, 2010, 02:46 PM