Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MAGIC 8 BALL: This program will ask the user to enter a yes/no question and it will then print out an appropriate yes or no

MAGIC 8 BALL: This program will ask the user to enter a yes/no question and it will then print out an appropriate yes or no response. Hint: You will have to read in the question into a string variable, but you dont really need it. Your program will generate a random number from 0 to 7 (depends on how many responses you want to have in your program) and it will print out a response based on the random number.( in c++ programming)

1.promptuser()

a.Does not return a value

b.Does not have arguments

c.This function will prompt the user (print out a message asking for a yes or no question). The function will read in the question into a string variable (even though we dont need it later).

2.getrandom()

a.Returns an integer which is the random number to be used

b.Does not have arguments

c.This function will generate a random number from 0 to 7 (depends on how many responses you have see below). The function will return the random number back to the main body.

3.Printresponse()

a.Does not return a value

b.It does have 1 argument, the random number. Based on this number the function will print out an appropriate response.

c.Use a switch statement and depending on what the random number is, print out a message. For example, if the random number

i.is 0, print out No way!.

ii.is 1, print out Unfortunately yes!

iii.is 2, print out YASSSS!

vi.is 3, print out I wish I could say yes

v.is 4, print out Of course not!

Etc

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