Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 score keeper is not working
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nin




PostPosted: Thu Jan 18, 2007 9:13 am   Post subject: score keeper is not working

what is the problem with my score keeper? i answered all the questions right but it says at the end that i only got 4 right? if i noe that i got them all right...

code:


%Set screen up
import GUI
setscreen ("graphics")

%Declaration Section
var mainWin := Window.Open ("graphic: 640;200")
var key : string (1)
var number, randomNum : int
var try : int := 3
var mainMenuBtn, playBtn, nextBtn, nextBtn2, nextBtn3, nextBtn4, nextBtn5, nextBtn6, nextBtn7,
    nextBtn8, nextBtn9, quitBtn, instructionBtn, playBtn2, mainMenuBtn2, goodByeBtn : int := 0
var score : int := 0
var answer := 2
var answer1 := 2
var answer3 := 3
var answer5 := 3
var answer4 := 4
var answer6 := 1000
var answer7 := 7692000
var answer8 := 361
var answer9 := 30
var answer10 := 18

%Title
proc title
    drawfillbox (0, 0, 640, 640, 170)
    colorback (170)
    locate (1, 36)
    put "Math Trivia"
end title

%Introduction
proc introduction
    GUI.Refresh
    title
    locate (3, 1)
    put "This program will be testing your math skills and also your concentration."
    locate (5, 1)
    put "This program will test your concentration by playing a music while playing."

    GUI.Show (mainMenuBtn)
end introduction

%Main Menu
proc mainMenu
    cls
    title
    locate (3, 1)
    put "To proceed, please press any of the below buttons."
    GUI.Show (playBtn)
    GUI.Show (quitBtn)
    GUI.Show (instructionBtn)
end mainMenu

%Instructions
proc instructions
    cls
    title
    locate (3, 1)
    put "Instructions: "
    locate (5, 1)
    put "For multiple choice questions pick your answer between 1, 2, 3, and 4."
    put "But remember that there is only one right answer among the 4 choices given."
    locate (8, 1)
    put "For the answerable questions, you are able to type any answer that you wish."
    put "Remember that the answerable questions only accept numbers and not words. "
    locate (11, 1)
    put "After you have written your answer, please press enter."
    put "This applies to both, multiple choice and answerable questions. "

    GUI.Show (playBtn2)
    GUI.Show (mainMenuBtn2)
end instructions

%Questions 1-5 error message
proc errorMessage
    var windID1 := Window.Open ("position:300;300,graphics: 330;100")
    locate (1, 1)
    put "Please enter 1, 2, 3 or 4."
    locate (5, 1)
    put "To proceed, please press any key" ..
    loop
        exit when hasch
    end loop
    Window.Close (windID1)
end errorMessage

%Question 1
proc question1
    cls
    title
    locate (3, 1)
    put "How do you calculate the volume of a prism? "
    locate (5, 1)
    put "1.V = Area of base x height"
    put "2.V = 1/3 x area of base x height"     %right answer
    put "3.V = Base x 1/3 x base x height"
    put "4.V = Base x Height"
    locate (10, 1)
    put "Answer: " ..
    get number

    if number < 1 or number > 4 then
        errorMessage
        question1

        if number = answer then
            score := score + 1
        end if
    end if

    GUI.Show (nextBtn)
end question1

%Question2
proc question2
    cls
    title
    locate (3, 1)
    put "What is 70 percent of 70?"
    locate (5, 1)
    put "1. 70"
    put "2. 49"     %right answer
    put "3. 40"
    put "4. 100"
    locate (10, 1)
    put "Answer: " ..
    get number

    GUI.Show (nextBtn2)

    if number < 1 or number > 4 then
        errorMessage
        question2

        if number = answer1 then
            score := score + 1
        end if
    end if
end question2

%Question3
proc question3
    cls
    title
    locate (3, 1)
    put "How many degress in a straight angle?"
    locate (5, 1)
    put "1. 20 degrees"
    put "2. 360 degrees"
    put "3. 180 degrees"     %right answer
    put "4. 160 degrees"
    locate (10, 1)
    put "Answer: " ..
    get number
    GUI.Show (nextBtn3)

    if number < 1 or number > 4 then
        errorMessage
        question3
        if number = answer3 then
            score := score + 1
        end if
    end if
end question3

%Question4
proc question4
    cls
    title
    locate (3, 1)
    put "What is a decagon?"
    locate (5, 1)
    put "1. A 12 sided figure"
    put "2. A 16 sided figure"
    put "3. A 8 sided figure"
    put "4. A 10 sided figure"     %right answer
    locate (10, 1)
    put "Answer: " ..
    get number
    GUI.Show (nextBtn4)

    if number < 1 or number > 4 then
        errorMessage
        question4
        if number = answer4 then
            score := score + 1
        end if
    end if
end question4

%Question 5
proc question5
    cls
    title
    locate (3, 1)
    put "Who wrote 'The measurement of the circle'?"
    locate (5, 1)
    put "1. Aristarcus"
    put "2. Euclid"
    put "3. Archimedes"     %right answer
    put "4. Euler"
    locate (10, 1)
    put "Answer: " ..
    get number

    GUI.Show (nextBtn5)

    if number < 1 or number > 4 then
        errorMessage
        question5
        if number = answer5 then
            score := score + 1
        end if
    end if
end question5

%Question 6
proc question6
    cls
    title
    locate (3, 1)
    put "How many kilometres are there in a megametre?"
    % answer : 1000
    locate (5, 1)
    put "Answer: " ..
    get number

    if number = answer6 then
        score := score + 1
    end if

    GUI.Show (nextBtn6)
end question6

%Question 7
proc question7
    cls
    title
    locate (3, 1)
    put "What is 3000 x 2564 = "
    locate (5, 1)
    %answer: 7692000
    put "Answer: " ..
    get number

    if number = answer7 then
        score := score + 1
    end if
    GUI.Show (nextBtn7)
end question7

%Question 8
proc question8
    cls
    title
    locate (3, 1)
    put "Kelly was born on May 18 1969.Val was born on May 15 1970."
    put "How many days between their birthdates?"
    locate (6, 1)
    %answer: 361
    put "Answer: " ..
    get number

    if number = answer8 then
        score := score + 1
    end if

    GUI.Show (nextBtn8)
end question8

%Question 9
proc question9
    cls
    title
    locate (3, 1)
    put "What is the complement of 60 degrees?"
    locate (5, 1)
    %answer: 30
    put "Answer: " ..
    get answer

    if number = answer9 then
        score := score + 1
    end if

    GUI.Show (nextBtn9)
end question9

%Question 10
proc question10
    cls
    title
    locate (3, 1)
    put "It takes 12 minutes to saw a log into three pieces."
    put "How long does it take to saw it into 4 pieces?"
    locate (7, 1)
    %answer:18
    put "Answer: " ..
    get number

    if number = answer10 then
        score := score + 1
    end if

    GUI.Show (goodByeBtn)
end question10

%Good Bye
proc goodBye
    var windID2 := Window.Open ("graphics:640;400")
    drawfillbox (0, 0, 640, 640, 170)
    colorback (170)
    Window.Close (mainWin)
    locate (8, 32)
    put "Your Final score is: ", score
    locate (10, 29)
    put "This program was written by:"
    locate (11, 35)
    put "Ninanori Agustin"
    locate (13, 38)
    put "Credits to:"
    locate (14, 26)
    put "http://www.quia.com/cb/22904.html"
    locate (15, 32)
    put "For the math questions"
    locate (17, 39)
    put "Goodbye!"
    delay (4000)
    Window.Close (windID2)
end goodBye

%Buttons
playBtn := GUI.CreateButtonFull (282, 220, 0, "Start Game", question1, 0, '^P', false)
mainMenuBtn := GUI.CreateButtonFull (281, 180, 0, "Main Menu", mainMenu, 0, '^M', false)
quitBtn := GUI.CreateButton (302, 140, 0, "Exit", GUI.Quit)
instructionBtn := GUI.CreateButtonFull (278, 100, 0, "Instructions", instructions, 0, '^I', false)
playBtn2 := GUI.CreateButtonFull (525, 10, 0, "Play Game >>", question1, 0, '^J', false)
mainMenuBtn2 := GUI.CreateButtonFull (10, 10, 0, "<<Main Menu", mainMenu, 0, '^K', false)
goodByeBtn := GUI.CreateButtonFull (278, 10, 0, "Result", goodBye, 0, '^L', false)

%Next Buttons
nextBtn := GUI.CreateButtonFull (1, 216, 0, "Next", question2, 0, '^N', false)
nextBtn2 := GUI.CreateButtonFull (1, 190, 0, "Next", question3, 0, '^A', false)
nextBtn3 := GUI.CreateButtonFull (1, 164, 0, "Next", question4, 0, '^B', false)
nextBtn4 := GUI.CreateButtonFull (1, 138, 0, "Next", question5, 0, '^C', false)
nextBtn5 := GUI.CreateButtonFull (1, 112, 0, "Next", question6, 0, '^D', false)
nextBtn6 := GUI.CreateButtonFull (1, 86, 0, "Next", question7, 0, '^E', false)
nextBtn7 := GUI.CreateButtonFull (1, 60, 0, "Next", question8, 0, '^F', false)
nextBtn8 := GUI.CreateButtonFull (1, 34, 0, "Next", question9, 0, '^G', false)
nextBtn9 := GUI.CreateButtonFull (60, 216, 0, "Next", question10, 0, '^H', false)

%Main Program
introduction
loop
    exit when GUI.ProcessEvent
end loop
goodBye

%End of program

Sponsor
Sponsor
Sponsor
sponsor
apomb




PostPosted: Thu Jan 18, 2007 12:07 pm   Post subject: Re: score keeper is not working

Making multipul threads will not make people answer your question faster, it will just piss people off. so, take Cervante's comments from the other thread, and post BACK IN THAT THREAD. thank you, and have a nice day Smile
Cervantes




PostPosted: Thu Jan 18, 2007 12:24 pm   Post subject: RE:score keeper is not working

CompWiz333 is right. You've made many threads all about the same topic. The last two seem to be identical. I was about to say something myself. So, I'm locking this thread. You can continue asking questions in your first thread.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: