Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started