Question
Need Help with the following C++ Program: Complete a program that represents a Magic Eight Ball (a Magic Eight Ball allows you to ask questions
Need Help with the following C++ 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started