You will have to read in the question into a string


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 don't 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 don't 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!"

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: You will have to read in the question into a string
Reference No:- TGS02537340

Now Priced at $15 (50% Discount)

Recommended (98%)

Rated (4.3/5)