Write an interactive program that allows 1 person to play this game against the computer. Input This program has two types of input:
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Children often play the game of rock, paper, and scissors. This game has two players, each of whom chooses one of the three objects: rock, paper, or scissors. If player 1 chooses rock and player 2 chooses paper, player 2 wins the game because paper covers the rock. The game is played according to the following rules:
- If both players choose the same object, this play is a tie.
- If one player chooses rock and the other chooses scissors, the player
choosing the rock wins this play because the rock breaks the scissors.
- If one player chooses rock and the other chooses paper, the player
choosing the paper wins this play because the paper covers the rock.
- If one player chooses scissors and the other chooses paper, the player
choosing the scissors wins this play because the scissors cut the paper.
Write an interactive program that allows 1 person to play this game against the computer.
Input This program has two types of input:
- The users’ responses when asked to play the game.
- The players’ choices.
Output The players’ choices and the winner of each play. After the game is over, the total number of plays and the number of times that each player won should be output as well. (
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images