Question: Need help with the following program: Complete a program that represents a Magic Eight Ball (a Magic Eight Ball allows you to ask questions and
Need help with the following program:
Complete a program that represents a Magic Eight Ball (a Magic Eight Ball allows you to ask questions and receive one of several random answers).
In order to complete this, you will need a couple of new functions.
First, in order to get a line of input that can contain spaces, you cannot use cin, but instead will use getline:
string question;
cout << "What is your question? (Enter 'x' to exit)" << endl; getline(cin, question);
Second, an alternative to using == to compare two strings is the string compare function. We'll look later at reasons to use this, but
if (question.compare("x") == 0)
//found an "x"
Following code is provided to build program off of:
#include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
