Answer to Question #99422 in C++ for Caleb

Question #99422
Write a switch statement that checks nextChoice. If 0, print "Rock". If 1, print "Paper". If 2, print "Scissors". For any other value, print "Unknown". End with newline.
#include <iostream>
using namespace std;

int main() {
int nextChoice;

cin >> nextChoice;

/* Your solution goes here */

return 0;
}
1
Expert's answer
2019-12-09T14:02:00-0500
// Write a switch statement that checks nextChoice.
// If 0, print "Rock". If 1, print "Paper".
// If 2, print "Scissors". For any other value, print "Unknown". End with newline.
#include <iostream>
using namespace std;
int main() {
    int nextChoice;
    cin >> nextChoice;
    /* Your solution goes here */
    switch(nextChoice){
        case 0: cout<<"Rock"; break;
        case 1: cout<<"Paper"; break;
        case 2: cout<<"Scissors"; break;
        default: cout<<"Unknown"; break;
    }
    cout<<endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS