In a trivia script, how would you enter a fill in the blank question and an answer like the Seinfeld trivia game in Programming for Beginners? Please help - it is homework.

link|improve this question
2  
What have you tried? What concepts have you learned so far? It doesn't help you for someone to just provide the answer; show us what you've tried and where you're stuck, and people will be more willing to give helpful answers. – Stephen Jennings Nov 2 '10 at 5:46
feedback

3 Answers

There is the Read-Host cmdlet for reading input from the user, and you'll need some conditional logic to check against the correct answer.

link|improve this answer
feedback

As well as Read-Host you can directly use the System.Console class, to read a single character (without needing ENTER):

$key = [Console]::ReadKey()
$char = $key.KeyChar
link|improve this answer
#Ask the player the eighth question While ($question8 -eq "George"){ Clear-Host #clear the windows command console screen write-Host Write-Host "Fill in the blank" Write-Host Write-Host "_______is attacked by a hawk." Write-Host $question8 = Read-Host " Fill in the blank with the correct name" ` "and press the Enter key" } #Clear the Windows command console screen Clear-Host – Colby Ellsworth Nov 2 '10 at 22:02
This is what I have tried but no luck I have made some changes to it but can not figure out what I need to impute to get it to work – Colby Ellsworth Nov 2 '10 at 22:04
@Colby: Please edit the question to include further information (and from the code I expect you needed -neq (not equals) in the while condition). – Richard Nov 3 '10 at 8:25
feedback
#Ask the player the seventh question
while (($question7 -eq "")) {

  Clear-Host  #Clear the Windows command console screen

  Write-Host
  Write-Host " What food item did Jerry say Newman wouldn't eat even if it was deep fried in chocolate sauce?"
  Write-Host
  Write-Host " Broccoli"
  Write-Host " Peas"
  Write-Host " Apples"
  Write-Host " Carrots"
  Write-Host
  $question7 = Read-Host " Type the word representing the correct answer" `
    "and press the Enter key"

}
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.