Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CHALLENGE ACTIVITY 3.10.1: Rock-paper-scissors Write a switch statement that che

ID: 3747411 • Letter: C

Question

CHALLENGE ACTIVITY 3.10.1: Rock-paper-scissors 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 1 #include 2 3 int main(void) L 1 test passed int nextChoice; 6 scanf("%d", &nextChoice) ; All tests passed 8 Your solution goes here/ 10 return 0; Run Feedback? CHALLENGE ACTIVITY 3.10.2: Switch statement to convert letters to Greek letters Write a switch statement that checks origLetter. If 'a' or 'A, print "Alpha. If 'b' or 'B', print "Beta". For any other character, print "Unknown'. Use fall-through as appopriate. End with newline 1 #include 2 3 int main(void) 4char origLetter; 1 test passed 6 scanf(" c", &origLetter); 7 All tests passed 8 Your solution goes here*/ 10 return 0;

Explanation / Answer

1) #include int main(void) { int nextChoice; scanf("%d", &nextChoice); switch(nextChoice) { case 0: printf("Rock "); break; case 1: printf("Paper "); break; case 2: printf("Scissors "); break; default: printf("Unknown "); break; } return 0; } 2) #include int main(void) { char origLetter; scanf(" %c", &origLetter); switch(origLetter) { case 'a': case 'A': printf("Alpha "); break; case 'b': case 'B': printf("Beta "); break; default: printf("Unknown "); break; } return 0; }