Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!