You can use the script on any Windows computer. Copy the code below into a text file and then name that file something like multiply.ps1. The file needs to end in .ps1 for Windows to recognize it as PowerShell.
You may also need to allow PowerShell scripts on your computer. Open a PowerShell prompt and run Set-ExecutionPolicy RemoteSigned.
If you have the file saved on your desktop, right-click it and select Run with Windows PowerShell
Clear-Host
$questions = Read-Host "How many questions?"
For($i=1;$i -le $questions;$i++) {
$first = Get-Random -Minimum 0 -Maximum 10
$second = Get-Random -Minimum 0 -Maximum 10
$answer = $first * $second
Do {
Clear-Host
Write-Host "$first x $second = ??"
$response = Read-Host "Enter your answer"
If ($response -eq $answer) {
Write-Host "That is correct!"
}
Else {
Write-Host "Try Again"
Pause
Clear-Host
}
}
Until ($response -eq $answer)
}
Clear-Host
Write-Host "Well done! $questions questions completed!"
Pause
No comments:
Post a Comment