Results 1 to 9 of 9
Thread: Could any help me please?
 08202009, 01:51 AM #1Member
 Join Date
 Aug 2009
 Posts
 4
 Rep Power
 0
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; 08202009 at 12:55 PM. Reason: Difficult for me to explain..

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.
 08202009, 02:13 AM #3Member
 Join Date
 Aug 2009
 Posts
 4
 Rep Power
 0
i will post it here sir

Good. We will be on the lookout for it. Best of luck.
 08202009, 04:16 AM #5
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,372
 Blog Entries
 1
 Rep Power
 20
 08202009, 12:46 PM #6Member
 Join Date
 Aug 2009
 Posts
 4
 Rep Power
 0
Hello sir i will not yet finish this question. I find it very difficult sir.

Well you still have our hopes and prayers for a successful attempt. Good luck.
 08202009, 01:14 PM #8Member
 Join Date
 Aug 2009
 Posts
 4
 Rep Power
 0
Thank you sir.
 08212009, 04:29 AM #9
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,372
 Blog Entries
 1
 Rep Power
 20
Bookmarks