Computer Science Canada New bees newbee program! |
Author: | theman [ Thu Jan 29, 2004 8:48 pm ] |
Post subject: | New bees newbee program! |
This is a program that i made for school. It's sort of a contest. Lets see how many of you can answer the questions!! (most are pretty easy though) PS. I YOU GET SOME BITS, PLEASE!?!: %declaration section import GUI %getch var key : string (1) %name var name : string %buttons var exitp, draw1, draw2, draw3, draw4, draw5, draw6, mainmenu, main : int := 0 %answer to question(userInput) var input6 : int var input7, input8, input9, input10 : int %percentage var score10, score9, score8, score7, score6, score5, score4, score3, score1, score2, total : int %Writing var font1, font2, font3, font4, font5 : int font1 := Font.New ("Juice ITC:30") assert font1 > 0 font2 := Font.New ("Juice ITC:100") assert font2 > 0 font3 := Font.New ("Matura MT Script Capitals:58") assert font3 > 0 font4 := Font.New ("Matura MT Script Capitals:16") assert font4 > 0 font5 := Font.New ("Matisse ITC:30") assert font5 > 0 %background var star, star1 : int := 200 var num := 50 Draw.FillBox (0, 0, maxx, maxy, 7) locate (13, 25) colorback (7) %This is the stars in the background for x : 1 .. 200 randint (star, 1, 640) randint (star1, 1, 400) for f : 1 .. 20 drawdot (star, star1, 0) delay (1) drawdot (star, star1, 0) end for end for %Border for x : 0 .. 640 drawbox (0, 1, 0 + x, 1, 0) drawbox (4, 5, 0 + x, 5, 0) drawbox (8, 9, 0 + x, 9, 0) drawbox (12, 13, 0 + x, 13, 0) drawbox (16, 17, 0 + x, 17, 0) drawbox (20, 21, 0 + x, 21, 0) drawbox (0, 398, 0 + x, 398, 0) drawbox (4, 394, 0 + x, 394, 0) drawbox (8, 390, 0 + x, 390, 0) drawbox (12, 386, 0 + x, 386, 0) drawbox (16, 382, 0 + x, 382, 0) drawbox (20, 378, 0 + x, 378, 0) drawbox (0, 1, 0, 0 + x, 0) drawbox (4, 5, 4, 0 + x, 0) drawbox (8, 9, 8, 0 + x, 0) drawbox (12, 13, 12, 0 + x, 0) drawbox (16, 17, 16, 0 + x, 0) drawbox (20, 21, 20, 0 + x, 0) drawbox (620, 398, 620, 398 - x, 0) drawbox (624, 394, 624, 398 - x, 0) drawbox (628, 390, 628, 398 - x, 0) drawbox (632, 386, 632, 398 - x, 0) drawbox (636, 382, 636, 398 - x, 0) drawbox (640, 378, 640, 398 - x, 0) delay (8) end for %progess bar for x : 0 .. 500 Font.Draw ("Math", 80, 260, font2, 0) delay (10) Font.Draw ("Contest", 300, 180, font2, 0) drawbox (70 + x, 125, 70, 113, 0) delay (1) locate (18, 40) color (103) put x div 5, "%" .. locate (17, 10) put "Loading..." .. end for play ("2<d>2>d<") delay (1000) process playmusic %music for x : 1 .. 3 play ("8>c<8<b>8>b<8<c>8<b>8>b<8<c>8<b>8>b<8<c>8<b>8<c>8>a<8>a<8>a<8>b<8>c<8<b>8>b<8<c>8<b>8>b<8<c>") play ("8<b>8>b<8<c>8<b>8>b<8<c>8<b>8>b<8<c>8<b>8<c>8>a<8>a<8>a<8>b<8>c<8<b>8>b<8<c>8<b>8>b<8<c>8<b>8>b<8<c>8<b>8<c>8>a<8>a<8>a<8>b<") end for end playmusic fork playmusic %procedures procedure title cls %background Draw.FillBox (0, 0, maxx, maxy, 255) locate (13, 25) color (0) colorback (black) %This is the design in the background %This is the stars in the background for x : 1 .. 300 randint (star, 1, 640) randint (star1, 1, 400) drawdot (star, star1, 14) end for %title Font.Draw ("Math", 270, 368, font1, 103) Font.Draw ("Contest", 320, 330, font1, 103) end title procedure pauseProgram color (0) locate (10, 26) put "Press any key to countinue..." locate (11, 40) getch (key) cls end pauseProgram procedure intro title %intro Font.Draw ("This a math test containg 10 math question.", 130, 300, font4, 103) Font.Draw ("5 of which are multiple choice and 5 that are answerable.", 70, 280, font4, 103) pauseProgram end intro procedure goodBye title locate (8, 28) put "This program was written" .. locate (10, 39) put "by:" .. Font.Draw ("THE MAN", 50, 150, font3, 0) end goodBye procedure dis setscreen ("graphics:360;500") drawfillbox (0, 0, 360, 500, 78) drawfillbox (5, 35, 355, 475, 55) Font.Draw ("Hi-Score", 100, 430, font5, 53) color (53) colorback (55) Font.Draw ("Name", 10, 380, font5, 53) Font.Draw ("Score", 240, 380, font5, 53) locate (10, 2) put "1. ", name locate (12, 2) put "2. -" .. locate (14, 2) put "3. -" .. locate (16, 2) put "4. -" .. locate (18, 2) put "5. -" .. locate (20, 2) put "6. -" .. locate (22, 2) put "7. -" .. locate (24, 2) put "8. -" .. locate (26, 2) put "9. -" .. locate (28, 2) put "10. -" .. total := score10 + score9 + score8 + score7 + score6 + score5 + score4 + score3 + score1 + score2 locate (10, 34) put total, "%" locate (12, 34) put " - " locate (14, 34) put " - " locate (16, 34) put " - " locate (18, 34) put " - " locate (20, 34) put " - " locate (22, 34) put " - " locate (24, 34) put " - " locate (26, 34) put " - " locate (28, 34) put " - " %border for x : 1 .. 445 drawfillbox (5, 35, 0, 35 + x, 54) drawfillbox (355, 35, 360, 35 + x, 54) delay (1) end for for x : 1 .. 360 drawfillbox (0, 475, 0 + x, 480, 54) drawfillbox (0, 35, 0 + x, 30, 54) delay (5) end for if total <= 50 then for x : 1 .. 350 Font.Draw ("Could have done better!!", -300 + x, 0, font1, 0) delay (10) Font.Draw ("Could have done better!!", -300 + x, 0, font1, 78) end for Font.Draw ("Could have done better!!", 50, 0, font1, 0) else for x : 1 .. 350 Font.Draw ("Good Job!!", -200 + x, 0, font1, 0) delay (10) Font.Draw ("Good Job!!", -200 + x, 0, font1, 78) end for Font.Draw ("Good Job!!", 150, 0, font1, 0) end if GUI.Show (main) end dis procedure namep GUI.Disable (draw6) title setscreen ("graphics:360;500") drawfillbox (0, 0, 360, 500, 78) drawfillbox (5, 35, 355, 475, 55) Font.Draw ("Hi-Score", 130, 430, font5, 53) color (53) colorback (55) %border for x : 1 .. 445 drawfillbox (5, 35, 0, 35 + x, 54) drawfillbox (355, 35, 360, 35 + x, 54) delay (1) end for for x : 1 .. 360 drawfillbox (0, 475, 0 + x, 480, 54) drawfillbox (0, 35, 0 + x, 30, 54) delay (5) end for locate (10, 2) put "Please enter your name:" .. locate (11, 2) get name dis end namep procedure userInput10 GUI.Disable (draw6) title GUI.Show (mainmenu) locate (7, 1) put "10) What is the sum of 12 and 23 and 100?" .. locate (8, 1) get input10 draw6 := GUI.CreateButton (300, 150, 16, "Submit", namep) if input10 = 135 then score10 := 10 else score10 := 0 end if end userInput10 procedure userInput9 GUI.Disable (draw6) title GUI.Show (mainmenu) locate (7, 1) put "9) The sum of four positive integers is 22. What is the largest possible product of these four integers?" .. locate (9, 1) get input9 draw6 := GUI.CreateButton (300, 150, 16, "Submit", userInput10) if input9 = 900 then score9 := 10 else score9 := 0 end if end userInput9 procedure userInput8 GUI.Disable (draw6) title GUI.Show (mainmenu) locate (6, 1) put "8) At most how many Sundays can occur in a single year?" .. locate (7, 1) get input8 draw6 := GUI.CreateButton (300, 150, 16, "Submit", userInput9) if input8 = 53 then score8 := 10 else score8 := 0 end if end userInput8 procedure userInput7 GUI.Disable (draw6) title locate (7, 1) GUI.Show (mainmenu) put "7) What is 23 x 2?" .. locate (8, 1) get input7 draw6 := GUI.CreateButton (300, 150, 16, "Submit", userInput8) if input7 = 46 then score7 := 10 else score7 := 0 end if end userInput7 procedure userInput6 GUI.Disable (draw1) GUI.Disable (draw2) GUI.Disable (draw3) GUI.Disable (draw4) title if GUI.GetEventWidgetID = draw2 then score5 := 10 else score5 := 0 end if GUI.Show (mainmenu) locate (7, 1) put "6)What is the diameter of a circle with the radius of 12?" .. locate (8, 1) get input6 draw6 := GUI.CreateButton (300, 150, 16, "Submit", userInput7) if input6 = 24 then score6 := 10 else score6 := 0 end if end userInput6 procedure userInput5 GUI.Disable (draw1) GUI.Disable (draw2) GUI.Disable (draw3) GUI.Disable (draw4) title if GUI.GetEventWidgetID = draw2 then score4 := 10 else score4 := 0 end if locate (7, 1) GUI.Show (mainmenu) put "1) An amusement park charges $8 for an adult ticket, and $6 for a children's ticket. On a certain day, a total of 150 tickets were sold for a total cost of $1020. How many more children's tickets were sold than adult tickets?" .. draw1 := GUI.CreateButton (175, 200, 16, "50", userInput6) draw2 := GUI.CreateButton (275, 200, 16, "30", userInput6) draw3 := GUI.CreateButton (375, 200, 16, "102", userInput6) draw4 := GUI.CreateButton (475, 200, 16, "90", userInput6) end userInput5 procedure userInput4 GUI.Disable (draw1) GUI.Disable (draw2) GUI.Disable (draw3) GUI.Disable (draw4) title if GUI.GetEventWidgetID = draw2 then score3 := 10 else score3 := 0 end if locate (6, 1) GUI.Show (mainmenu) put "1)A family pays $800 per year for an insurance plan that pays 80 percent of the first $1,000 in expenses and 100 percent of all medical expenses thereafter." .. put "In any given year, the total amount paid by the family will equal the amount paid by the plan when the family's medical expenses total which of the following?" .. draw1 := GUI.CreateButton (175, 200, 16, "$1000", userInput5) draw2 := GUI.CreateButton (275, 200, 16, "$1200", userInput5) draw3 := GUI.CreateButton (375, 200, 16, "$8000", userInput5) draw4 := GUI.CreateButton (475, 200, 16, "$600", userInput5) end userInput4 procedure userInput3 GUI.Disable (draw1) GUI.Disable (draw2) GUI.Disable (draw3) GUI.Disable (draw4) title if GUI.GetEventWidgetID = draw2 then score2 := 10 else score2 := 0 end if locate (7, 1) GUI.Show (mainmenu) put "1) 123 x 12=" .. draw1 := GUI.CreateButton (175, 200, 16, "1440", userInput4) draw2 := GUI.CreateButton (275, 200, 16, "1476", userInput4) draw3 := GUI.CreateButton (375, 200, 16, "144", userInput4) draw4 := GUI.CreateButton (475, 200, 16, "1236", userInput4) end userInput3 procedure userInput2 GUI.Disable (draw1) GUI.Disable (draw2) GUI.Disable (draw3) GUI.Disable (draw4) title if GUI.GetEventWidgetID = draw2 then score1 := 10 else score1 := 0 end if locate (7, 1) GUI.Show (mainmenu) put "2) 123 + 3934 + 230948 =" .. draw1 := GUI.CreateButton (175, 200, 16, "324546", userInput3) draw2 := GUI.CreateButton (275, 200, 16, "235005", userInput3) draw3 := GUI.CreateButton (375, 200, 16, "12354", userInput3) draw4 := GUI.CreateButton (475, 200, 16, "230006", userInput3) end userInput2 procedure userInput1 GUI.Disable (exitp) GUI.Disable (draw5) title GUI.Show (mainmenu) locate (7, 1) put "Lets start the test!!!" .. locate (8, 1) put "1) x+y=39" .. locate (10, 1) put " y=24" .. locate (12, 1) put " x=?" .. draw1 := GUI.CreateButton (175, 200, 16, "x=12", userInput2) draw2 := GUI.CreateButton (275, 200, 16, "x=15", userInput2) draw3 := GUI.CreateButton (375, 200, 16, "x=4", userInput2) draw4 := GUI.CreateButton (475, 200, 16, "x=139", userInput2) end userInput1 procedure mainMenu setscreen ("graphics:640;400") title color (0) Font.Draw ("Click either of the two buttons to move on", 130, 300, font4, 0) draw5 := GUI.CreateButton (1, 200, 16, "Take the test", userInput1) exitp := GUI.CreateButton (1, 25, 16, "Exit this program", goodBye) end mainMenu main := GUI.CreateButton (150, 480, 16, "MainMenu", mainMenu) mainmenu := GUI.CreateButton (450, 340, 16, "Go back to Main menu", mainMenu) %main program intro mainMenu loop exit when GUI.ProcessEvent end loop goodBye |