Question: Can you complete code for Powershell Programming so CMDLETS My code isnt working properly 1 . Update the switch statement. Each code block in the

Can you complete code for Powershell Programming so CMDLETS My code isnt working properly 1. Update the switch statement. Each code block in the if statements should include a line to increment one of the following variables: the variable holding the number of wins, the variable holding the number of losses, or the variable holding the number of ties. You will add each statement just before the Write-Host cmdlet. You will increment each by one. For example, $noTied +=1.
2. $computerMoveNum ="" #Variable to store the numeric version of the computer's move
3. $robotChoiceNum ="" #Computer's numeric choice
4. $robotChoiceWord ="" #Computer's Word choice
5.
6. $playerChoiceWord ="" #Player's Word choice
7. $playerChoiceLet ="" #Player's letter choice
8.
9. $tie ="" #Variable to keep track of tied games
10.
11. $gamePlay = $true #To control gameplay
12. $gamesPlayed ="" #Number of games played
13. $gamesLost ="" #Variable to keep track of the number of games lost
14. $gamesWon ="" #Variable to keep track of games won
15.
16. #Clears screen before beginning, writes welcome message on screen
17. cls
18. Write-host "Welcome to the `n `n `vRock, Paper, Scissors Game"
19. Write-host "`n `v `vPress Enter to continue"
20. $player = Read-Host
21. Start-Sleep -seconds 0.5; Read-Host
22.
23. while ($gamePlay = $true)
24.{
25.
26. cls
27. #Chooses a random number between 1 and 3; 1=Rock 2=Paper 3=Scissors
28. $robotChoiceNum = Get-Random -Minimum 1-Maximum 4
29.
30. #Sets number to matching word
31. if ($robotChoiceNum -eq 1)
32.{
33. $robotChoiceWord = "Rock"
34.}
35. if ($robotChoiceNum -eq 2)
36.{
37. $robotChoiceWord = "Paper"
38.}
39. if ($robotChoiceNum -eq 3)
40.{
41. $robotChoiceWord = "Scissors"
42.}
43.
44. while ($playerChoiceLet ="")
45.{
46. cls
47. Write-Host "Enter one of the following options: "
48. $dash ="-"*35
49. Write-Host $dash`n
50. Write-Host "R = Rock `nP = Paper `nS = Scissors `nQ = Quit`n"
51. Write-Host $dash`n
52. #Write-Host "Make a move "
53.
54. # Validate player's move
55. $playerChoiceLet = Read-Host "Make a move"
56.}
57. if ($playerChoiceLet -eq "Q")
58.{
59. Clear-Host
60. Write-Host "Thank you for playing!"
61. $gamePlay = $true
62. continue #Skip the remainder of the loop
63.}
64. elseif ($playerChoiceLet -notin "R","P","S")
65.{
66. Write-Host "Invalid input. Please try again."
67. $playerChoice = Read-Host "Make your move:"
68. continue #Skip the remainder of the loop
69.}
70.
71. switch ($playerChoiceLet) #Translate player's letter value to word value
72.{
73."R"{ $playerChoiceWord = "Rock" }
74."P"{ $playerChoiceWord = "Paper" }
75."S"{ $playerChoiceWord = "Scissors" }
76.}
77.
78. switch ($playerChoiceWord) #Compare the computer's and player moves to determine winner
79.{
80."R"{
81. switch ($robotChoiceNum)
82.{
83.1{ Write-Host "It's a tie! Both chose Rock." }
84.2{ Write-Host "Computer wins! Paper beats Rock." }
85.3{ Write-Host "You win! Rock beats Scissors." }
86.}
87.}
88.
89."P"{
90. switch ($robotChoiceNum)
91.{
92.1{ Write-Host "You win! Paper beats Rock." }
93.2{ Write-Host "It's a tie! Both chose Paper." }
94.3{ Write-Host "Computer wins! Scissors beat Paper." }
95.}
96.}
97.
98."S"{
99. switch ($robotChoiceNum)
100.{
101.1{ Write-Host "Computer wins! Rock beats Scissors." }
102.2{ Write-Host "You win! Scissors beat Paper." }
103.3{ Write-Host "It's a tie! Both chose Scissors." }
104.}
105.}
106.}
107.
108.
109. Write-Host `n `n "Results: "
110. Write-Host $dash`n
111. Write-Host "You picked: " $playerChoiceWord
112. Write-Host "The computer picked: " $robotChoiceWord
113. Write-Host $dash`n
114.}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!