QUESTION IMAGE
Question
activity 2.6.1: rock-paper-scissors. organize the lines of code to create a switch statement that checks nextchoice. if the input is 0, then the output is: rock if the input is 1, then the output is: paper if the input is 2, then the output is: scissors for any other input, the output is: unknown how to use this tool unused case 1: case 2: case 0: cout << \unknown\ << endl; cout << \paper\ << endl; break; switch (nextchoice) { cout << \scissors\ << endl; break; } cout <<
ock\ << endl; break; default: main.cpp load default template... #include <iostream> using namespace std; int main() { int nextchoice; cin >> nextchoice; return 0; }
Step1: Add switch statement header
switch (nextChoice) {
Step2: Add case 0 for Rock
case 0:
cout << "Rock" << endl;
break;
Step3: Add case 1 for Paper
case 1:
cout << "Paper" << endl;
break;
Step4: Add case 2 for Scissors
case 2:
cout << "Scissors" << endl;
break;
Step5: Add default for Unknown
default:
cout << "Unknown" << endl;
Step6: Close switch statement
}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 complete main.cpp code is:
#include <iostream>
using namespace std;
int main() {
int nextChoice;
cin >> nextChoice;
switch (nextChoice) {
case 0:
cout << "Rock" << endl;
break;
case 1:
cout << "Paper" << endl;
break;
case 2:
cout << "Scissors" << endl;
break;
default:
cout << "Unknown" << endl;
}
return 0;
}