
-----------------------------------
Genisis
Tue Nov 15, 2005 10:38 am

my quiz program
-----------------------------------
colorback (black)
cls
color (white)




var Qtype : string
var Q1, Q2, Q3, Q4, Q5, mark : int
var try : string
var totalmark : real
mark := 0
loop
    %computer
    drawfillbox (450, 170, 560, 280, yellow)
    drawbox (440, 160, 570, 290, white)
    drawbox (420, 100, 590, 150, white)
    %cross
    drawline (100, 100, 100, 200, white)
    drawline (150, 100, 150, 200, white)
    drawline (50, 200, 50, 250, white)
    drawline (200, 200, 200, 250, white)
    drawline (100, 250, 100, 300, white)
    drawline (150, 250, 150, 300, white)
    drawline (100, 100, 150, 100, white)
    drawline (100, 100, 150, 100, white)
    drawline (50, 200, 100, 200, white)
    drawline (50, 250, 100, 250, white)
    drawline (150, 300, 100, 300, white)
    drawline (150, 200, 200, 200, white)
    drawline (150, 250, 200, 250, white)
    drawfill (145, 200, yellow, white)
    %E=MC
    var font, font2 : int
    font := Font.New ("Times New Roman:40")
    font2 := Font.New ("Times New Roman:20")
    Font.Draw ("E=M", 250, 50, font, brightred)
    Font.Draw ("c", 360, 75, font2, brightred)

    put "Pick which type of quiz you would like out of : "
    put "- Computers"
    put "- Religon"
    put "- Math"

    get Qtype
    delay (2000)
    cls
    loop

        %quiz 1 with computers
        if Qtype = "Computers" or Qtype = "computers" or Qtype = "computer" then
            put "What is the biggest part of hardware on a home computer"
            put "1) Motherboard"
            put "2) Video Card"
            put "3) Etehrnet Card"
            drawfillbox (450, 170, 560, 280, yellow)
            drawbox (440, 160, 570, 290, white)
            drawbox (420, 100, 590, 150, white)
            get Q1
            if Q1 = 1 then
                mark := mark + 1


            end if

            delay (1000)
            cls
            put "What drive doesnt work on most of the computers here at school?"
            put "1) D drive"
            put "2) CD drive"
            put "3) A drive"
            drawfillbox (450, 170, 560, 280, yellow)
            drawbox (440, 160, 570, 290, white)
            drawbox (420, 100, 590, 150, white)
            get Q2
            if Q2 = 2 then
                mark := mark + 1

            end if


            delay (1000)
            cls
            put "What is the name of the creator of Windows?"
            put " 1) Bill Martin"
            put " 2) Bill Park"
            put " 3) Bill Gates"
            drawfillbox (450, 170, 560, 280, yellow)
            drawbox (440, 160, 570, 290, white)
            drawbox (420, 100, 590, 150, white)
            get Q3
            if Q3 = 3 then
                mark := mark + 1

            end if
            delay (1000)
            cls
            put "What is a Hard Drive"
            put "1) useless drive"
            put "2) storage drive"
            put "3) a drive that makes the copmputer run faster"
            drawfillbox (450, 170, 560, 280, yellow)
            drawbox (440, 160, 570, 290, white)
            drawbox (420, 100, 590, 150, white)
            get Q4
            if Q4 = 2 then
                mark := mark + 1

            end if

            delay (1000)
            cls
            put " Where does the sound come from on the school computers?"
            put "1) a monitor"
            put "2) internal speakers"
            put "3) external speakers"
            drawfillbox (450, 170, 560, 280, yellow)
            drawbox (440, 160, 570, 290, white)
            drawbox (420, 100, 590, 150, white)
            get Q5
            if Q5 = 2 then
                mark := mark + 1

            end if
            totalmark := (mark / 5) * 100

            delay (2000)
            cls
            drawfillbox (450, 170, 560, 280, yellow)
            drawbox (440, 160, 570, 290, white)
            drawbox (420, 100, 590, 150, white)
            exit
            %second quiz religon
        elsif Qtype = "Religon" or Qtype = "religon" or Qtype = "relgion" then
            put "Who saved India from Britian?"
            put "1) Buddha"
            put "2) Gandhi"
            put "3) Goerge Bush"
            drawline (100, 100, 100, 200, white)
            drawline (150, 100, 150, 200, white)
            drawline (50, 200, 50, 250, white)
            drawline (200, 200, 200, 250, white)
            drawline (100, 250, 100, 300, white)
            drawline (150, 250, 150, 300, white)
            drawline (100, 100, 150, 100, white)
            drawline (100, 100, 150, 100, white)
            drawline (50, 200, 100, 200, white)
            drawline (50, 250, 100, 250, white)
            drawline (150, 300, 100, 300, white)
            drawline (150, 200, 200, 200, white)
            drawline (150, 250, 200, 250, white)
            drawfill (145, 200, yellow, white)
            get Q1
            if Q1 = 2 then
                mark := mark + 1

            end if
            delay (1000)
            cls
            put "Who is the enlightened one?"
            put "1) Buddha"
            put "2) Gandhi"
            put "3) Bushto"
            drawline (100, 100, 100, 200, white)
            drawline (150, 100, 150, 200, white)
            drawline (50, 200, 50, 250, white)
            drawline (200, 200, 200, 250, white)
            drawline (100, 250, 100, 300, white)
            drawline (150, 250, 150, 300, white)
            drawline (100, 100, 150, 100, white)
            drawline (100, 100, 150, 100, white)
            drawline (50, 200, 100, 200, white)
            drawline (50, 250, 100, 250, white)
            drawline (150, 300, 100, 300, white)
            drawline (150, 200, 200, 200, white)
            drawline (150, 250, 200, 250, white)
            drawfill (145, 200, yellow, white)
            get Q2
            if Q2 = 1 then
                mark := mark + 1
            end if
            delay (1000)
            cls
            put "What is the National Religion of Japan?"
            put "1) Shintoism"
            put "2) Buddhism"
            put "3) Hinduism"
            drawline (100, 100, 100, 200, white)
            drawline (150, 100, 150, 200, white)
            drawline (50, 200, 50, 250, white)
            drawline (200, 200, 200, 250, white)
            drawline (100, 250, 100, 300, white)
            drawline (150, 250, 150, 300, white)
            drawline (100, 100, 150, 100, white)
            drawline (100, 100, 150, 100, white)
            drawline (50, 200, 100, 200, white)
            drawline (50, 250, 100, 250, white)
            drawline (150, 300, 100, 300, white)
            drawline (150, 200, 200, 200, white)
            drawline (150, 250, 200, 250, white)
            drawfill (145, 200, yellow, white)
            get Q3
            if Q3 = 1 then
                mark := mark + 1
            end if
            delay (1000)
            cls
            put "Where is the Dali Lama from?"
            put "1) China"
            put "2) Tibet"
            put "3) India"
            drawline (100, 100, 100, 200, white)
            drawline (150, 100, 150, 200, white)
            drawline (50, 200, 50, 250, white)
            drawline (200, 200, 200, 250, white)
            drawline (100, 250, 100, 300, white)
            drawline (150, 250, 150, 300, white)
            drawline (100, 100, 150, 100, white)
            drawline (100, 100, 150, 100, white)
            drawline (50, 200, 100, 200, white)
            drawline (50, 250, 100, 250, white)
            drawline (150, 300, 100, 300, white)
            drawline (150, 200, 200, 200, white)
            drawline (150, 250, 200, 250, white)
            drawfill (145, 200, yellow, white)
            get Q4
            if Q4 = 2 then
                mark := mark + 1
            end if
            delay (1000)
            cls
            put "Who is the new pope?"
            put "1) Pope John Paul II"
            put "2) Pope Benedict XVI"
            put "3) Pope St. Pius X"
            drawline (100, 100, 100, 200, white)
            drawline (150, 100, 150, 200, white)
            drawline (50, 200, 50, 250, white)
            drawline (200, 200, 200, 250, white)
            drawline (100, 250, 100, 300, white)
            drawline (150, 250, 150, 300, white)
            drawline (100, 100, 150, 100, white)
            drawline (100, 100, 150, 100, white)
            drawline (50, 200, 100, 200, white)
            drawline (50, 250, 100, 250, white)
            drawline (150, 300, 100, 300, white)
            drawline (150, 200, 200, 200, white)
            drawline (150, 250, 200, 250, white)
            drawfill (145, 200, yellow, white)
            get Q5
            if Q5 = 2 then
                mark := mark + 1
            end if
            totalmark := (mark / 5) * 100
            delay (1000)
            cls
            drawline (100, 100, 100, 200, white)
            drawline (150, 100, 150, 200, white)
            drawline (50, 200, 50, 250, white)
            drawline (200, 200, 200, 250, white)
            drawline (100, 250, 100, 300, white)
            drawline (150, 250, 150, 300, white)
            drawline (100, 100, 150, 100, white)
            drawline (100, 100, 150, 100, white)
            drawline (50, 200, 100, 200, white)
            drawline (50, 250, 100, 250, white)
            drawline (150, 300, 100, 300, white)
            drawline (150, 200, 200, 200, white)
            drawline (150, 250, 200, 250, white)
            drawfill (145, 200, yellow, white)
            exit
            %quiz 3 math
        elsif Qtype = "Math" or Qtype = "math" then
            put "what is 1 + 1?"
            put "1) 1"
            put "2) 2"
            put "3) 11"
            font := Font.New ("Times New Roman:40")
            font2 := Font.New ("Times New Roman:20")
            Font.Draw ("E=M", 250, 50, font, brightred)
            Font.Draw ("c", 360, 75, font2, brightred)
            get Q1
            if Q1 = 2 then
                mark := mark + 1
            end if
            delay (1000)
            cls
            put " What is the order of operations?"
            put "1) BEDMAS"
            put "2) Dewey Decimal System"
            put "3) pi"
            font := Font.New ("Times New Roman:40")
            font2 := Font.New ("Times New Roman:20")
            Font.Draw ("E=M", 250, 50, font, brightred)
            Font.Draw ("c", 360, 75, font2, brightred)
            get Q2
            if Q2 = 1 then
                mark := mark + 1
            end if
            delay (1000)
            cls
            put "Suppose five days before the day after tomorrow was Wednesday what is today?"
            put "1) Saturday"
            put "2) Sunday"
            put "3) Monday"
            font := Font.New ("Times New Roman:40")
            font2 := Font.New ("Times New Roman:20")
            Font.Draw ("E=M", 250, 50, font, brightred)
            Font.Draw ("c", 360, 75, font2, brightred)
            get Q3
            if Q3 = 1 then
                mark := mark + 1
            end if
            delay (1000)
            cls
            put "A freight train travels 1 mile in 1 minute 30 seconds."
            put "At this rate, how many miles will the train travel in 1 hour?"
            put "1) 40"
            put "2) 45"
            put "3) 50"
            font := Font.New ("Times New Roman:40")
            font2 := Font.New ("Times New Roman:20")
            Font.Draw ("E=M", 250, 50, font, brightred)
            Font.Draw ("c", 360, 75, font2, brightred)
            get Q4
            if Q4 = 1 then
                mark := mark + 1
            end if
            delay (1000)
            cls

            put " what is 50-10*2/40^2+60-40+3*8-6"
            put "1) 87.9873"
            put "2) 87.9875"
            put "3) 87.9874"
            font := Font.New ("Times New Roman:40")
            font2 := Font.New ("Times New Roman:20")
            Font.Draw ("E=M", 250, 50, font, brightred)
            Font.Draw ("c", 360, 75, font2, brightred)
            get Q5
            if Q5 = 2 then
                mark := mark + 1
            end if
            totalmark := (mark / 5) * 100
            delay (1000)
            cls
            font := Font.New ("Times New Roman:40")
            font2 := Font.New ("Times New Roman:20")
            Font.Draw ("E=M", 250, 50, font, brightred)
            Font.Draw ("c", 360, 75, font2, brightred)
            exit
        end if

    end loop
    put "Your mark was ", totalmark, "%"
    delay (5000)
    cls
    put "Would you like to try agian? y/n"
    get try
    if try = "n" or try = "no" then
       
        exit
    end if
    cls
end loop

-----------------------------------
do_pete
Tue Nov 15, 2005 11:58 am


-----------------------------------
you should put the answers and questions in an array and make your code less linear. good start tho

-----------------------------------
Tony
Tue Nov 15, 2005 12:55 pm


-----------------------------------
Do you notice how you have the same lines repeat over and over?

...
delay (1000)
cls
put " What is the order of operations?"
put "1) BEDMAS"
put "2) Dewey Decimal System"
put "3) pi"
font := Font.New ("Times New Roman:40")
font2 := Font.New ("Times New Roman:20")
Font.Draw ("E=M", 250, 50, font, brightred)
Font.Draw ("c", 360, 75, font2, brightred)
get Q2
if Q2 = 1 then
mark := mark + 1
end if
delay (1000)
cls
put "Suppose five days before the day after tomorrow was Wednesday what is today?"
put "1) Saturday"
put "2) Sunday"
put "3) Monday"
font := Font.New ("Times New Roman:40")
font2 := Font.New ("Times New Roman:20")
Font.Draw ("E=M", 250, 50, font, brightred)
Font.Draw ("c", 360, 75, font2, brightred)
get Q3
if Q3 = 1 then
mark := mark + 1
end if
delay (1000)
cls

...


only the bold parts vary, the rest is the same. It's obvious that you need to use a loop here. This way when you add another question, you just have to load question/answer values, and not have the same 15 lines repeat over and over. The entire program could be under 20 lines and have an indefinate amount of questions.
