Results 1 to 9 of 9
  1. #1
    JoyMe is offline Member
    Join Date
    Aug 2009
    Posts
    4
    Rep Power
    0

    Post Could any help me please?

    public class Twodice{
    public static int NUM_GAMES = 10000;

    public static void main(String[] args) {
    int numWins = 0;
    int numLosses = 0;

    int x = (int)(Math.random()*6) + 1;
    int y = (int)(Math.random()*6) + 1;

    System.out.println("The roll of first Dice is " + x);
    System.out.println("The roll of Second Dice is " + y);

    int roll = (x + y);

    System.out.println("The sum of two dice is " + (roll));

    int point = (4 & 5 & 6 & 8 & 9 & 10);

    for (int i = 1; i<=10000; i++)
    if (roll == 7 || roll == 11) {
    System.out.println("You win!");
    numWins = numWins +1;
    } else if (roll==2 || roll==3 || roll==12) {
    System.out.println("You Lose!");
    numLosses = numLosses + 1;
    } else {
    System.out.println("Roll Dice again!!!");
    int thePoint = roll;
    do {
    x = (int)(Math.random()*6) + 1;
    y = (int)(Math.random()*6) + 1;

    roll = (x + y);
    if (roll == thePoint)
    numWins++;
    else if(roll == 7)
    numLoses++;
    } while (roll != 7 || roll != thePoint);
    }
    }

    System.out.println("In the simulation, we won " + numWins +
    " times and lost " + numLosses + " times, ");
    System.out.println("for a probability of " +
    (double)(numWins)/(double)(numWins + numLosses));
    }
    }


    //------------------------------------------------------------------------------------------
    //A player rolls two dice. Each die has six faces. These faces contain one, two, three,
    //four, five and six spots, respectively. After the dice have come to rest, the sum of
    //the spots on the two upward faces is calculated. If the sum is 7 or 11 on the first throw,
    //the player wins. If the sum is 2, 3 or 12 on the first throw (called “craps”), the player
    //loses. If the sum is 4, 5, 6, 8, 9 or 10 on the first throw, that sum becomes the player’s
    //“point.” To win, you must continue rolling the dice until you “make your point” (i.e., roll
    //your point value). The player loses by rolling a 7 before making the point.
    -------------------------------------------------------------------------------------------

    Hope it is correct. i find it errors in System.out.println and also how would i make it into a JApplet? Makes my head spinning sir.
    Last edited by JoyMe; 08-20-2009 at 12:55 PM. Reason: Difficult for me to explain..

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Without seeing your attempt at a solution, we have no idea of where you're making a mistake, so please post your code so that we may better help you.

    When posting code, also please use code tags to make it readable (see FAQ and my signature below). Oh, and welcome to the forum.

  3. #3
    JoyMe is offline Member
    Join Date
    Aug 2009
    Posts
    4
    Rep Power
    0

    Default

    i will post it here sir

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by JoyMe View Post
    i will post it here sir
    Actually this waht you've do in very first post lol. ;)

  6. #6
    JoyMe is offline Member
    Join Date
    Aug 2009
    Posts
    4
    Rep Power
    0

    Default

    Hello sir i will not yet finish this question. I find it very difficult sir.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  8. #8
    JoyMe is offline Member
    Join Date
    Aug 2009
    Posts
    4
    Rep Power
    0

    Default

    Thank you sir.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by JoyMe View Post
    Hello sir i will not yet finish this question. I find it very difficult sir.
    At the minute just forget about the applet stuff, correct all the errors in this code.

    Can you post the complete error here to see?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •