' By Svjatoslav Agejenko.\r
' Email: svjatoslav@svjatoslav.eu\r
' Homepage: http://www.svjatoslav.eu\r
-'\r
+\r
' Changelog:\r
' 2000, Initial version\r
' 2024, Improved program readability using AI\r
\r
-DECLARE SUB vastus ()\r
+DECLARE SUB showGreetingAndSetup ()\r
DEFINT A-Y\r
-DECLARE SUB tere ()\r
-DIM SHARED nimi$\r
-DIM SHARED kus\r
+DECLARE SUB getUserInputAndDisplayQuestions ()\r
+DIM SHARED userName$\r
+DIM SHARED numberOfQuestions\r
\r
-tere\r
-vastus\r
+showGreetingAndSetup\r
+getUserInputAndDisplayQuestions\r
\r
DEFINT Z\r
-SUB tere\r
+SUB showGreetingAndSetup\r
\r
' Clear the screen and set up graphics mode\r
CLS\r
FOR y = 3 TO 20\r
FOR x = 0 TO 320\r
IF POINT(x, y) > 0 THEN\r
- c = y + 56\r
+ colorIndex = y + 56\r
ELSE\r
- c = 31 - y / 2\r
+ colorIndex = 31 - y / 2\r
END IF\r
- PSET (x, y), c\r
+ PSET (x, y), colorIndex\r
NEXT x\r
NEXT y\r
\r
' Get user input for their name\r
LOCATE 5, 1\r
COLOR 7\r
-INPUT "Enter your name ", nimi$\r
+INPUT "Enter your name ", userName$\r
LOCATE 5, 1\r
COLOR 8\r
-PRINT "Enter your name " + nimi$\r
+PRINT "Enter your name " + userName$\r
\r
' Greet the user\r
LOCATE 6, 1\r
COLOR 7\r
-PRINT "Hello " + nimi$ + "!"\r
+PRINT "Hello " + userName$ + "!"\r
\r
8\r
LOCATE 7, 1\r
PRINT SPACE$(35)\r
COLOR 7\r
LOCATE 7, 1\r
-INPUT "How many questions would you like ? ", kus\r
+INPUT "How many questions would you like ? ", numberOfQuestions\r
LOCATE 7, 1\r
COLOR 8\r
PRINT SPACE$(35)\r
LOCATE 7, 1\r
COLOR 8\r
-PRINT "How many questions would you like ?" + STR$(kus)\r
+PRINT "How many questions would you like? " + STR$(numberOfQuestions)\r
\r
' Validate the number of questions\r
-IF kus < 5 THEN\r
+IF numberOfQuestions < 5 THEN\r
PRINT "That would be too easy !"\r
GOTO 8\r
END IF\r
\r
-IF kus > 30 THEN\r
+IF numberOfQuestions > 30 THEN\r
PRINT "That would be too hard !"\r
GOTO 8\r
END IF\r
NEXT\r
\r
' Initialize color array\r
-DIM varv(1 TO 32)\r
+DIM colorArray(1 TO 32)\r
\r
-c = 4\r
-d = 1\r
+currentColorIndex = 4\r
+colorChangeDirection = 1\r
\r
2\r
FOR a = 0 TO 31\r
' Draw vertical lines with decreasing brightness\r
- LINE (a * 10, 170)-(a * 10 + 10, 190), 200 + varv(a + 1), BF\r
- varv(a + 1) = varv(a + 1) - 1\r
- IF varv(a + 1) < 0 THEN varv(a + 1) = 0\r
+ LINE (a * 10, 170)-(a * 10 + 10, 190), 200 + colorArray(a + 1), BF\r
+ colorArray(a + 1) = colorArray(a + 1) - 1\r
+ IF colorArray(a + 1) < 0 THEN colorArray(a + 1) = 0\r
NEXT a\r
\r
' Change the color index\r
-c = c + d\r
-IF c > 30 OR c < 3 THEN d = -d\r
-varv(c) = 30\r
+currentColorIndex = currentColorIndex + colorChangeDirection\r
+IF currentColorIndex > 30 OR currentColorIndex < 3 THEN colorChangeDirection = -colorChangeDirection\r
+colorArray(currentColorIndex) = 30\r
SOUND 0, 1\r
\r
' Check if user is ready\r
END SUB\r
\r
DEFSNG Z\r
-SUB vastus\r
+SUB getUserInputAndDisplayQuestions\r
RANDOMIZE TIMER\r
\r
-mitmes = 0\r
-vale = 0\r
-oige = 0\r
+numberOfAttempts = 0\r
+incorrectAnswers = 0\r
+correctAnswers = 0\r
PRINT "How much is:"\r
4\r
-mitmes = mitmes + 1\r
-IF mitmes > kus THEN GOTO 6\r
+numberOfAttempts = numberOfAttempts + 1\r
+IF numberOfAttempts > numberOfQuestions THEN GOTO 6\r
\r
' Generate random numbers for multiplication\r
-ar1 = RND * 9\r
-ar2 = RND * 9\r
-a$ = STR$(ar1) + " X" + STR$(ar2)\r
+multiplier1 = RND * 9\r
+multiplier2 = RND * 9\r
+question$ = STR$(multiplier1) + " X" + STR$(multiplier2)\r
PRINT " "\r
-PRINT a$\r
+PRINT question$\r
\r
5\r
-INPUT vas$\r
+INPUT userAnswer$\r
\r
' Handle invalid inputs\r
-IF LEFT$(vas$, 6) = "don't know" THEN\r
+IF LEFT$(userAnswer$, 6) = "don't know" THEN\r
PRINT "Try at least !"\r
GOTO 5\r
END IF\r
\r
' Convert input to number\r
-IF vas$ = "0" THEN\r
- vas = 0\r
+IF userAnswer$ = "0" THEN\r
+ userAnswer = 0\r
GOTO 10\r
ELSE\r
- vas = VAL(vas$)\r
- IF vas = 0 THEN vas = -1\r
+ userAnswer = VAL(userAnswer$)\r
+ IF userAnswer = 0 THEN userAnswer = -1\r
END IF\r
\r
10\r
\r
' Check if the answer is correct\r
-IF ar1 * ar2 = vas THEN\r
- oige = oige + 1\r
+IF multiplier1 * multiplier2 = userAnswer THEN\r
+ correctAnswers = correctAnswers + 1\r
PRINT "Correct !"\r
ELSE\r
PRINT "Wrong !"\r
- PRINT "Correct answer is ", ar1 * ar2\r
- vale = vale + 1\r
+ PRINT "Correct answer is ", multiplier1 * multiplier2\r
+ incorrectAnswers = incorrectAnswers + 1\r
END IF\r
\r
GOTO 4\r
6\r
PRINT "-------------------------"\r
COLOR 2\r
-PRINT "Wrong answers :", vale\r
+PRINT "Incorrect answers: ", incorrectAnswers\r
\r
' Calculate the score\r
-z = oige / kus * 100\r
+scorePercentage = correctAnswers / numberOfQuestions * 100\r
\r
-hinne = 1\r
+grade = 1\r
\r
' Determine the grade\r
-IF z >= 25 THEN hinne = 2\r
-IF z >= 50 THEN hinne = 3\r
-IF z >= 70 THEN hinne = 4\r
-IF z >= 90 THEN hinne = 5\r
+IF scorePercentage >= 25 THEN grade = 2\r
+IF scorePercentage >= 50 THEN grade = 3\r
+IF scorePercentage >= 70 THEN grade = 4\r
+IF scorePercentage >= 90 THEN grade = 5\r
\r
COLOR 14\r
-PRINT "Your grade is: "; hinne\r
-END SUB
\ No newline at end of file
+PRINT "Your grade is: "; grade\r
+END SUB\r