Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,37 @@
supervisor:
GOSUB initialize
GOSUB guessing
GOTO continue
initialize:
RANDOMIZE TIMER
n = 0: r = INT(RND * 100 + 1): g = 0: c$ = ""
RETURN
guessing:
WHILE g <> r
INPUT "Pick a number between 1 and 100"; g
IF g = r THEN
PRINT "You got it!"
n = n + 1
PRINT "It took "; n; "tries to pick the right number."
ELSEIF g < r THEN
PRINT "Try a larger number."
n = n + 1
ELSE
PRINT "Try a smaller number."
n = n + 1
END IF
WEND
RETURN
continue:
WHILE c$ <> "YES" AND c$ <> "NO"
INPUT "Do you want to continue? (YES/NO)"; c$
c$ = UCASE$(c$)
IF c$ = "YES" THEN
GOTO supervisor
ELSEIF c$ = "NO" THEN
STOP
END IF
WEND

View file

@ -0,0 +1,49 @@
' OPTION EXPLICIT ' Remove remark for VB-DOS/PDS 7.1
'dIM
' Var
DIM n AS INTEGER, g AS INTEGER, t AS INTEGER, a AS STRING
CONST c = 10
' Functions
DECLARE FUNCTION getNumber () AS INTEGER
' Program to guess a number between 1 and 10
DO
CLS
PRINT "Program to guess a number between 1 and 10"
n = getNumber()
t = 0
DO
t = t + 1
DO
PRINT "Type a number (between 1 and " + FORMAT$(c) + "): ";
INPUT "", g
IF g < 1 OR g > c THEN BEEP
LOOP UNTIL g > 0 AND g < (c + 1)
' Compares the number
SELECT CASE g
CASE IS > n: PRINT "Try a lower number..."
CASE IS < n: PRINT "Try a higher number..."
CASE ELSE: PRINT "You got it! Attempts: " + FORMAT$(t)
END SELECT
LOOP UNTIL n = g
PRINT
PRINT "Do you want to try again? (Y/n)"
DO
a = UCASE$(INKEY$)
IF a <> "" AND a <> "Y" AND a <> "N" THEN BEEP
LOOP UNTIL a = "Y" OR a = "N"
LOOP UNTIL a = "N"
PRINT
PRINT "End of the program. Thanks for playing."
END
FUNCTION getNumber () AS INTEGER
' Generates a random number
' between 1 and the c Constant
RANDOMIZE TIMER
getNumber = INT(RND * c) + 1
END FUNCTION