Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that simulates a Magic 8 Ball, which is a fortune - telling toy that displays a random response to a yes or

Write a program that simulates a Magic 8 Ball, which is a fortune-telling toy that displays a random response to a yes or no question.
You should write a program consisting of two classes, one class containing the main method and the second class containing the MagicEightBall class from which a Magic 8 Ball object will be created.
The main method will ask the user for a yes-no question and generate a random number which shall be passed to the MagicEightBall object.
Use the Random class to generate a random number between 0 and 11 within the main method.
The MagicEightBall class will have a constructor and methods to access an array or ArrayList object.
Below, you will see a list of 12 responses such as "I don't think so", "Yes, of course", "I'm not sure", and so forth.
The 12 responses should be placed into an array or ArrayList object using a constructor.
The random number passed to the MagicEightBall class shall be used to select one of the responses from the array or ArrayList object.
The response retrieved from the array or ArrayList object shall be passed back to the main method where it will be displayed to the user.
The program should repeat until the user is ready to quit.
Responses to the user's question include the following:
Yes, of course!
Without a doubt, yes.
You can count on it.
For sure!
Ask me later.
I'm not sure.
I can't tell you right now.
I'll tell you after my nap.
No way!
I don't think so.
Without a doubt, no.
The answer is clearly NO!

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

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions