

Task

Obtain a valid   Y   or   N   response from the keyboard.

The keyboard should be flushed, so that any outstanding key-presses are removed, preventing any existing   Y   or   N   key-press from being evaluated.

The response should be obtained as soon as   Y   or   N   are pressed, and there should be no need to press an   enter   key.




// flush the keyboard
while key.available
    key.get
end while
 
// and now prompt and wait for Y or N
print "Press Y or N:"
k = ""
while k != "Y" and k != "N"
    k = key.get.upper
end while
print "You pressed: " + k