asked 54.8k views
5 votes
How do I write code in Java for "A spinner for a game has four possible options: blue, red, yellow, green. The chance of landing on each option is equal. Simulate using the spinner 15 times and reporting the resulting color."?

asked
User Sixta
by
8.2k points

1 Answer

5 votes
What you need to do is to generate a random number between 1 and 4(or0 and 3) 15 times. Each time you generate a number, you figure out which number it is and keep track of how many times you’ve seen that number. At the end, print out how many of each number you got.

Good luck!
answered
User Celeriko
by
8.1k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.