QUESTION IMAGE
Question
organize the lines of code to create an if - else statement that outputs goodbye, ending with a newline, if userstring is quit. otherwise, output hello, ending with a newline. note: not all lines of code on the left will be used in the final solution. how to use this tool unused cout << \goodbye\; cout << \goodbye\ << endl; else { else if { cout << \hello\ << endl; cout << \hello\; } if (userstring == \quit\) { if (userstring = \quit\) { } main.cpp #include <iostream> #include <string> using namespace std; int main() { string userstring; cin >> userstring; return 0; }
Step1: Add condition check block
if (userString == "Quit") {
Step2: Add goodbye output with newline
cout << "Goodbye" << endl;
Step3: Add else block
} else {
Step4: Add hello output with newline
cout << "Hello" << endl;
Step5: Close else block
}Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
The completed main.cpp code is:
#include <iostream>
#include <string>
using namespace std;
int main() {
string userString;
cin >> userString;
if (userString == "Quit") {
cout << "Goodbye" << endl;
} else {
cout << "Hello" << endl;
}
return 0;
}