Problem

Write a program that simulates the Magic 8 Ball game. Upon running the program, generate a...

Write a program that simulates the Magic 8 Ball game. Upon running the program, generate a random number such that one of the following 8 responses is output:

It is certainIt is decidedly soMost likelySigns point to yesReply hazy, try againAsk again laterDon’t count on itMy sources say no

There should be an equal chance for any one of the eight responses to come up. The program should ask the user if he or she would like to repeat the program and loop if the user opts to repeat. Random number generation is discussed in Chapter 6, but for this program you can use the following line of code to generate a random number between 1 and 8: ;

int num = (int) (Math.random() * 8) + 1

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
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