Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Magic 8-Ball is a fortune telling toy that provides responses like Yes it is certain or Ask again later when the user shakes it.

The Magic 8-Ball is a fortune telling toy that provides responses like Yes it is certain or Ask again later when the user shakes it. Your job is to create a Java program that simulates this behavior. You may want to refer to the following Wikipedia article for a description of Magic 8-Ball behavior and some possible messages: https://en.wikipedia.org/wiki/Magic_8-Ball (Links to an external site.)

Requirements:

Your program must: Use a while loop to repeatedly prompt the user to ask a question until they specify that they would like to quit. Use Math.random() to generate random "predictions" from at least 4 possible messages, and display that prediction to the user. You may select 4 from the Wikipedia link above, or make up your own. Log each of your questions and predictions to a file named predictions.txt, and display that file when the user exits the program. Use a try-catch block as shown in class. Do not use the "throws" keyword. Your code that actually generates your prediction should go in a method named getPrediction(), which returns a String.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is the purpose of a data communications standard?

Answered: 1 week ago

Question

Evaluate the importance of the employee handbook.

Answered: 1 week ago

Question

Discuss the steps in the progressive discipline approach.

Answered: 1 week ago