Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://i.imgur.com/XVfrg0k.png
- main:
- START
- userType = printMainMenu()
- IF userType == 1 THEN
- DO
- operationsType = printOptionMenu()
- IF operationsType != 4 THEN
- levelType = printLevelMenu()
- IF levelType != 4 THEN
- DO
- correctQuestion = 0
- i = 0
- WHILE i < 10
- correctQuestion += printQuestion(operationsType, levelType)
- i++
- END WHILE
- DISPLAY "You did " & correctQuestion & " out of 10 questions"
- IF correctQuestion >= 8 && levelType <=3 THEN
- continueOrExit = finishedQuestionCongrats()
- IF continueOrExit == 1 THEN
- levelType++
- ELSE
- continueOrExit--
- END IF
- ELSE
- continueOrExit = finishedQuestion()
- END IF
- IF continueOrExit == 2 THEN
- levelType = 4
- END IF
- WHILE continueOrExit == 1
- END IF
- END IF
- WHILE levelType == 4 && operationsType != 4
- END IF
- END
- http://i.imgur.com/ssA5laG.png
- printQuestion:
- START (operationsType, levelType)
- IF levelType == 1 THEN
- range = 11
- ELSE IF levelType == 2 THEN
- range = 101
- ELSE IF levelType == 3 THEN
- range = 1001
- END IF
- num1 = rand() % range
- num2 = rand() % range
- IF operationsType == 1 THEN
- answer = num1 + num2
- DISPLAY num1 & " + " & num2 & " = "
- ELSE IF operationsType == 2 THEN
- answer = num1 - num2
- DISPLAY num1 & " - " & num2 & " = "
- ELSE IF operationsType == 3 THEN
- answer = num1 * num2
- DISPLAY num1 & " * " & num2 & " = "
- END IF
- GET userAns
- IF userAns == answer THEN
- DISPLAY "You answer is correct"
- result = 1
- ELSE
- DISPLAY "Your answer is incorrect, " & answer & " is the correct answer"
- result = 0
- END IF
- RETURN result
- END
- http://i.imgur.com/klSapQB.png
- printMainMenu:
- START
- DISPLAY "Welcome to math quiz"
- DISPLAY "(1) Start the math quiz"
- DISPLAY "(2) Exit the math quiz"
- userInput = getUserInput(1,2)
- RETURN userInput
- END
- printOptionMenu:
- START
- DISPLAY "Please choose a arthimetic operations"
- DISPLAY "(1) +"
- DISPLAY "(2) -"
- DISPLAY "(3) *"
- DISPLAY "(4) Exit"
- userInput = getUserInput(1,4)
- RETURN userInput
- END
- printLevelMenu:
- START
- DISPLAY "Please choose a level"
- DISPLAY "(1) Beginner"
- DISPLAY "(2) Intermediate"
- DISPLAY "(3) Advanced"
- DISPLAY "(4) Back to arthimetic options"
- userInput = getUserInput(1,4)
- RETURN userInput
- END
- finishedQuestion:
- START
- DISPLAY "Choose an option"
- DISPLAY "(1) Continue"
- DISPLAY "(2) Exit to menu"
- userInput = getUserInput(1,2)
- RETURN userInput
- END
- finishedQuestionCongrats:
- START
- DISPLAY "You're such a genius, congratulations you have owned all the questions"
- DISPLAY "Choose an option"
- DISPLAY "(1) To next level"
- DISPLAY "(2) Continue with same level"
- DISPLAY "(3) Exit to menu"
- userInput = getUserInput(1,3)
- RETURN userInput
- END
- getUserInput:
- START
- DO
- DISPLAY "Select an option"
- GET userType
- IF userType < min || userType > max THEN
- DISPLAY "Error! Invalid option!"
- END IF
- WHILE userType < min || userType > max
- RETURN userType
- END
Advertisement
Add Comment
Please, Sign In to add comment