if($guess -lt ($number + 10)) { #The player's guess was too high Clear-Host #Clear the Windows command console screen Write-Host "`n Sorry. Your guess was too high. You are getting hot. Press Enter to" ` "guess again." Write-Host "`n The secret number was: $number." $guess = "" #Reset the player's guess Read-Host #Pause the game until the player presses the Enter key } elseif($guess -lt ($number + 20)) { #The player's guess was too high Clear-Host #Clear the Windows command console screen Write-Host "`n Sorry. Your guess was too high. You are getting warmer. Press Enter to" ` "guess again." Write-Host "`n The secret number was: $number." $guess = "" #Reset the player's guess Read-Host #Pause the game until the player presses the Enter key } else ($guess -gt $number) { #The player's guess was too high Clear-Host #Clear the Windows command console screen Write-Host "`n Sorry. Your guess was too high. You are getting warmer. Press Enter to" ` "guess again." Write-Host "`n The secret number was: $number." $guess = "" #Reset the player's guess Read-Host #Pause the game until the player presses the Enter key } if ($guess -gt ($number - 10)) { #The player's guess was too low Clear-Host #Clear the Windows command console screen Write-Host "`n Sorry. Your guess was too low. You are getting hot. Press Enter to" ` "guess again." Write-Host "`n The secret number was: $number." $guess = "" #Reset the player's guess Read-Host #Pause the game until the player presses the Enter key } elseif ($guess -gt ($number - 20)) { #The player's guess was too low Clear-Host #Clear the Windows command console screen Write-Host "`n Sorry. Your guess was too low. You are getting warm. Press Enter to" ` "guess again." Write-Host "`n The secret number was: $number." $guess = "" #Reset the player's guess Read-Host #Pause the game until the player presses the Enter key } else ($guess -lt $number) { #The player's guess was too low Clear-Host #Clear the Windows command console screen Write-Host "`n Sorry. Your guess was too low. You are getting warmer. Press Enter to" ` "guess again." Write-Host "`n The secret number was: $number." $guess = "" #Reset the player's guess Read-Host #Pause the game until the player presses the Enter key } if ($guess -eq $number) { #The player has guessed the game's secret number Clear-Host #Clear the Windows command console screen Write-Host "`n Congratulations. You guessed my number! Press Enter" ` "to continue." Write-Host "`n The secret number was: $number." $status = "Stop" #Reset the player's guess Read-Host #Pause the game until the player presses the Enter key } #The player has elected to play again if ($reply -eq "Y") { #Reset variables to their default values $number = 0 $noOfGuesses = 0 $status = "Play" $guess = 0 } else { #The player has decided to quit playing $playGame = "No" #Modify variable indicating that it is time to #terminate game play } #Clear the Windows command console screen Clear-Host What does this mean?
It says my very first "else" statement running properly. I am not sure why this error is occuring
- Edited by Steven Leise 16 hours 58 minutes ago