import GUI
View.Set ("graphics:600;600,position:center;center,nobuttonbar,title:Danny's Math Quizzer")
var buttonst := 0
var diff := "Easy"
var problem := "Addition"
% Procedures
procedure start
var font := Font.New ("comic sans ms:15")
Font.Draw ("Welcome to the Math Qizzer!", 10, 560, font, 8)
buttonst := 1
var num1, num2, ans, dec, qnum, vec, rvec, rdec, correct : int
var per : real
dec := 560
qnum := 1
vec := 320
rvec := 20
rdec := 260
correct := 0
loop
if problem = "Subtraction" then
if diff = "Easy" then
randint (num2, 0, 4)
randint (num1, 4, 8)
elsif diff = "Medium" then
randint (num2, 4, 9)
randint (num1, 9, 12)
elsif diff = "Hard" then
randint (num2, 9, 14)
randint (num1, 14, 18)
end if
else
if diff = "Easy" then
randint (num1, 0, 4)
randint (num2, 0, 4)
elsif diff = "Medium" then
randint (num1, 4, 9)
randint (num2, 4, 9)
elsif diff = "Hard" then
randint (num1, 9, 14)
randint (num2, 9, 14)
end if
end if
if problem = "Addition" then
drawline (300, 0, 300, 600, 7)
drawline (0, 300, 600, 300, 7)
drawline (0, 580, 600, 580, 7)
drawline (0, 280, 600, 280, 7)
locatexy (vec, dec)
put qnum, ") ", num1, " + ", num2, " = " ..
get ans
dec := dec - 20
rdec := rdec - 20
qnum := qnum + 1
if qnum = 11 then
vec := vec + 120
dec := 560
end if
if qnum = 12 then
rvec := rvec + 120
rdec := 240
end if
if ans = num1 + num2 then
correct := correct + 1
locatexy (rvec, rdec)
put qnum - 1, ") ", "Correct"
else
locatexy (rvec, rdec)
put qnum - 1, ") ", "Incorrect"
end if
if qnum = 13 then
exit
end if
elsif problem = "Subtraction" then
drawline (300, 0, 300, 600, 7)
drawline (0, 300, 600, 300, 7)
drawline (0, 580, 600, 580, 7)
drawline (0, 280, 600, 280, 7)
locatexy (vec, dec)
put qnum, ") ", num1, " - ", num2, " = " ..
get ans
dec := dec - 20
rdec := rdec - 20
qnum := qnum + 1
if qnum = 11 then
vec := vec + 120
dec := 560
end if
if qnum = 12 then
rvec := rvec + 120
rdec := 240
end if
if ans = num1 - num2 then
correct := correct + 1
locatexy (rvec, rdec)
put qnum - 1, ") ", "Correct"
else
locatexy (rvec, rdec)
put qnum - 1, ") ", "Incorrect"
end if
if qnum = 13 then
exit
end if
elsif problem = "Multiplication" then
drawline (300, 0, 300, 600, 7)
drawline (0, 300, 600, 300, 7)
drawline (0, 580, 600, 580, 7)
drawline (0, 280, 600, 280, 7)
locatexy (vec, dec)
put qnum, ") ", num1, " x ", num2, " = " ..
get ans
dec := dec - 20
rdec := rdec - 20
qnum := qnum + 1
if correct = 1 then
correct := 0
end if
if qnum = 11 then
vec := vec + 120
dec := 560
end if
if qnum = 12 then
rvec := rvec + 120
rdec := 240
end if
if ans = num1 * num2 then
correct := correct + 1
locatexy (rvec, rdec)
put qnum - 1, ") ", "Correct"
else
locatexy (rvec, rdec)
put qnum - 1, ") ", "Incorrect"
end if
if qnum = 13 then
exit
end if
else
end if
end loop
per := correct / 12 * 100
locatexy (80, 40)
color (12)
put "Your score is ", per : 0 : 2, "%"
color (7)
locatexy (320, 260)
put "Program created by Danny Knight"
locatexy (320, 240)
put "Compiled using Turing 4.0.4c"
drawbox (380, 230, 450, 190, 7)
drawbox (360, 230, 430, 190, 7)
drawmapleleaf (430, 200, 380, 220, 7)
drawfill (370, 200, 12, 7)
drawfill (390, 210, 12, 7)
drawfill (440, 210, 12, 7)
drawline (300, 0, 300, 600, 7) % Splits the screen in half (horazontle)
drawline (0, 300, 600, 300, 7) % Splits the screen in half (verticle)
drawline (0, 580, 600, 580, 7) % Lable line (1/4 & 2/4)
drawline (0, 280, 600, 280, 7) % Lable line (3/4 & 4/4)
end start
procedure easy
diff := "Easy"
end easy
procedure medium
diff := "Medium"
end medium
procedure hard
diff := "Hard"
end hard
procedure addition
problem := "Addition"
end addition
procedure subtraction
problem := "Subtraction"
end subtraction
procedure multiplication
problem := "Multiplication"
end multiplication
procedure division
end division
% Screen Format
locatexy (110, 590)
put "Setup"
locatexy (420, 590)
put "Quizzer"
locatexy (110, 290)
put "Results"
locatexy (420, 290)
put "Credits"
drawline (300, 0, 300, 600, 7) % Splits the screen in half (horazontle)
drawline (0, 300, 600, 300, 7) % Splits the screen in half (verticle)
drawline (0, 580, 600, 580, 7) % Lable line (1/4 & 2/4)
drawline (0, 280, 600, 280, 7) % Lable line (3/4 & 4/4)
% Screen (1/4)
var font := Font.New ("comic sans ms:15")
Font.Draw ("Welcome to the Math Qizzer!", 10, 560, font, 7)
var startbutton := GUI.CreateButton (100, 400, GUI.INDENT, "Start!", start)
var check1 := GUI.CreateRadioButton (50, 500, "Easy", 0, easy)
var check2 := GUI.CreateRadioButton (50, 480, "Medium", check1, medium)
var check3 := GUI.CreateRadioButton (50, 460, "Hard", check2, hard)
var problem1 := GUI.CreateRadioButton (150, 500, "Addition", 0, addition)
var problem2 := GUI.CreateRadioButton (150, 480, "Subtraction", problem1, subtraction)
var problem3 := GUI.CreateRadioButton (150, 460, "Multiplication", problem2, multiplication)
loop
if buttonst = 1 then
GUI.Disable (startbutton)
GUI.Disable (check1)
GUI.Disable (check2)
GUI.Disable (check3)
GUI.Disable (problem1)
GUI.Disable (problem2)
GUI.Disable (problem3)
exit
end if
exit when GUI.ProcessEvent
end loop
|