Question

Write a java code that rolls three dice and counts how many times it takes to...

Write a java code that rolls three dice and counts how many times it takes to get the same numbers


in a series of runs
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Random;

class Main {

public static int DICE()

{

int number=3; // 3 turns

int sum = 0; // get sum

int roll = 0; // randome roll

Random rand = new Random(); // random object

for(int i = 0; i < number; i++)

{

roll = rand.nextInt(6)+1;

System.out.println("Dist: "+roll);

sum = sum + roll;

}

return sum;

}

public static void main(String[] args)

{

System.out.println(DICE());

}

}

Add a comment
Know the answer?
Add Answer to:
Write a java code that rolls three dice and counts how many times it takes to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT