Results 1 to 9 of 9

# Thread: hello please help me out

- 03-23-2009, 11:07 AM #1Member
- Join Date
- Mar 2009
- Posts
- 52

- Rep Power
- 0

- 03-23-2009, 11:23 AM #2Senior Member
- Join Date
- Jun 2008
- Posts
- 2,571

- Rep Power
- 10

Okay? And your question is?

- 03-23-2009, 11:26 AM #3Member
- Join Date
- Mar 2009
- Posts
- 52

- Rep Power
- 0

## Re@masjde

My question is how to write java code to solve this

- 03-23-2009, 11:32 AM #4Senior Member
- Join Date
- Jun 2008
- Posts
- 2,571

- Rep Power
- 10

With a text editor?

IOW, we are*not*simply going to*give*you finished code.

Give it, at least, a*try*. If/When you run into problems, post*your*code and a specific question, and we will be glad to help, but we are not a "homework service".

- 03-23-2009, 12:00 PM #5Member
- Join Date
- Mar 2009
- Posts
- 52

- Rep Power
- 0

## Re

dude i am really stucked with it...

i dnt know how to approach this problem using java

i thought this community is to help beginners...

- 03-23-2009, 12:06 PM #6Senior Member
- Join Date
- Jun 2008
- Posts
- 2,571

- Rep Power
- 10

So write a method that determines all possibilites (and keeps a count of them), select all those that are divisible by 4 or 6 (and keeps a count of them, use %), then divide the two.

That is, at least, possibility, which is what you want, I believe, actual probablity also uses how many rolls were made, and how many of those already fit the criteria, but even with those, the principle remains the same.

Where is the problem?

Edit: It is to*help*beginners, not to do their (home)work for them. You will have received descriptions of the algorithm to use, and will have received instructions on, at the least the basics of, Class construction, so*write*something. If you have a problem we will be gald to help, but we are*not*going to write for you. That would*not*help you, regardless of how much you*think*it might.Last edited by masijade; 03-23-2009 at 12:13 PM.

- 03-23-2009, 12:14 PM #7Member
- Join Date
- Mar 2009
- Posts
- 52

- Rep Power
- 0

yep...the sample space for this problem is 36 as there r 2 dice

so i have to use 2 for loops?

- 03-23-2009, 12:19 PM #8Senior Member
- Join Date
- Jun 2008
- Posts
- 2,571

- Rep Power
- 10

If you mean one loop per die with an if statement and two counters inside the second, that is one definate possibility.

- 03-23-2009, 12:25 PM #9Member
- Join Date
- Mar 2009
- Posts
- 52

- Rep Power
- 0

see i worked it out

class Probability

{

public void calculate()

{

double sampleSpace=36;

double count=0;

double probability=0;

for(int i =1;i<=6;i++)

{

for(int j=1;j<=6;j++)

{

if((i+j)%4==0 || (i+j)%6==0)

{

count++;

}

}

}

probability=count/sampleSpace;

System.out.println("Probability is:"+probability);

}

public static void main(String args[])

{

new Probability().calculate();

}

}

## Bookmarks