#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    A small task i cant handle.


    Task describtion: There are n>2 judges and each gives a mark to sportsmans performance. Two extreme marks (one highest and one lowest) are removed and artithmetical mean of remaining n-2 marks is calculated. Write a Java method to determine the sportsmans result.

    public static double result (double[] marks)


    CODE:


    public class Answer {

    public static void main (String[] args) {
    System.out.println (result (new double[]{0., 1., 2., 3., 4.}));
    // YOUR TESTS HERE
    }

    public static double result (double[] marks) {
    return 0.; // TODO!!! YOUR PROGRAM HERE
    }

    }
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Basic Java Program


    I am stuck trying to figure out this java program. Would be much appreciated if you could help.

    The game displays three symbols each showing either A, B or
    C where each symbol is equally likely to occur. The player wins if all the symbols are the
    same (eg B B B is displayed) or all three symbols are di erent (eg B A C is displayed).
    The cost of playing one round playCost (an integer greater than or equal to zero) and the
    number of rounds to play noOfRounds (an integer greater than or equal to zero) are input by
    the user of the program. The program should disallow negative input. An amount which is
    three times the cost of playing one round (i.e. 3 x playCost) is won if three symbols the same
    are displayed. An amount of two times the cost of playing one round (i.e. 2 x playCost) is
    won if the three symbols all di erent are displayed.
    Each round the three symbols should be displayed. Additionally show the cost that round,
    the total cost so far, the winnings that round, the total winnings so far and a running total
    of total winnings minus total costs each round. After all rounds have been played print out
    the number of rounds played and the average winnings (or losses) per round.

    I have to use the math.random somewhere but I am not sure where.

    thanks
  4. #3
  5. Daniel Schildsky
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2004
    Location
    KL, Malaysia.
    Posts
    1,540
    Rep Power
    1621

    Show some codes


    Show us what you have worked out so far.

    To answer your question, you have already told us the answer yourself:
    The game displays three symbols each showing either A, B or C where each symbol is equally likely to occur.
    From this statement, you can know that the 3 symbols can appear in a random fashion, where each of them has an equal probability to occur.

    So, you should declare a list or an array to store all available symbols. Use a random number generated by the math.random generator to decide which shape to show for each position. The random numbers generated must fall within the range of 0..2 inclusive.

    Now that you are given a conceptual design of the solution, work out the codes yourself and post again with specific quesetions if you are stuck somewhere.
    When the programming world turns decent, the real world will turn upside down.

IMN logo majestic logo threadwatch logo seochat tools logo