How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the 8th programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the 8th programming language
Table of Contents
Problem Statement
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.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the 8th programming language
Source code in the 8th programming language
\ get a yes or no response from the keyboard
: yes-no
con:key $20 bor
dup 'y n:= if ;; then
dup 'n n:= if ;; then
drop yes-no ;
: no? 'n n:= if "No" else "Yes" then . ;
"Yes or no? " con:print yes-no no?
cr bye
You may also check:How to resolve the algorithm Voronoi diagram step by step in the J programming language
You may also check:How to resolve the algorithm Queue/Definition step by step in the AWK programming language
You may also check:How to resolve the algorithm Range expansion step by step in the Lingo programming language
You may also check:How to resolve the algorithm Bell numbers step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Sorting algorithms/Selection sort step by step in the Ada programming language