|
B. Subroutines: Write
a program with the following specifications:
1. It should ask four questions that require a YES or NO answer.
2. The answer to each question should be obtained using the INKEY$
statement, getting either a Y or N.
3. A subroutine using the GOSUB should be used to evaluate each
answer.
4. If the answer is Y, the "YOUR ANSWER IS AFFIRMATIVE"
should be printed to the monitor.
5. If the answer is Y, the "YOUR ANSWER IS NEGATIVE" should
be printed to the monitor.
6. The program should ignore any keystroke which not a Y or N.
CLS
PRINT "Do you like apples?";
GOSUB Question1
PRINT "Do you like grapes?";
GOSUB Question1
PRINT "Do you like oranges?";
GOSUB Question1
PRINT "Do you like bananas?";
GOSUB Question1
END
Question1:
A$ = INKEY$
IF A$ <> "y" AND A$ <> "n" THEN
GOTO Question1
IF A$ = "y" THEN PRINT "Your Answer Is Afirmative"
IF A$ = "n" THEN PRINT " Your Answer Is Negative"
RETURN |