
-----------------------------------
uknowhoiam
Sat Nov 29, 2008 12:35 am

Need Help with my random questions
-----------------------------------
I tried so many times but still cant fix this problem, i made a sports trivia game, everything is fine, except the random questions, sometimes the question repeat, anyone out there wanna help me?

Here's my code so far..


var number_q : int := 0
var answer : string
var name : string
var points : int := 0
var bank : int := 0
var finish : int := 0
var ch : string (1)
var random : int := 0

loop %If the user answers yes to play again, this loop will loop the program again"
    points := points - points
    finish := finish - finish
    colourback (black)
    cls
    colour (green + 1 + 5)
    put "How Well Do You Know Soccer?!!"
    put "please introduce yourself"
    get name : *
    put name, " How many questions do you want to answer? (Max is 10)"
    put "The more questions you answer the bigger prize you get!"
    put "If you get a question wrong, your score will be subtracted by two and if you getone right you will get 5 points"
    get number_q


    for count : 1 .. 10         % This 'for' loops is used for the 10 questions
        bank := Rand.Int (1, 10)

        case bank of            %The case of bank
            label 1 :           %If bank is 1 then..
                finish := finish + 1         %when finish will equal to how many questions the user wants

                put "Who replaced David Seaman as England's third choice goalkeeper in the 1990 World Cup squad after Seaman injured his thumb in training?"
                put "(a) Yao Ching"
                put "(b) David James"
                put "(c) Ralph"
                put "(d) Nigel Martyn"

                loop            %If the user gets the answer wrong, this will ask the user to enter an answer again
                    get answer
                    case answer of              %The case of answer
                        label "a" :
                            put "Wrong, Try again"
                            points := points - 2            %Subtracting score
                        label "b" :
                            put "Nope"
                            points := points - 2
                        label "c" :
                            put "No"
                            points := points - 2
                        label "d" :
                            put "Yes you are right"
                            points := points + 5

                            exit
                        label :
                            put "Choose one of the four options"
                    end case
                end loop


            label 2 :               %If bank is 2 then..
                finish := finish + 1

                put "Who was the first black footballer to win a full England cap?"
                put "(a) Viv Anderson"
                put "(b) Steve Coppell"
                put "(c) Tony Currie"
                put "(d) Brian Clough"

                loop
                    get answer
                    case answer of
                        label "a" :
                            put "You got it right!!!"
                            points := points + 5

                            exit
                        label "b" :
                            put "Wrong"
                            points := points - 2
                        label "c" :
                            put "Try Again"
                            points := points - 2
                        label "d" :
                            put "No"
                            points := points - 2
                        label :
                            put "Choose one of the four options"
                    end case
                end loop


            label 3 :                   %If bank is 3 then..
                finish := finish + 1

                put "Where was the 1986 World Cup held?"
                put "(a) Russia"
                put "(b) Brazil"
                put "(c) Canada"
                put "(d) Mexico"

                loop
                    get answer
                    case answer of
                        label "a" :
                            put "Nope"
                            points := points - 2
                        label "b" :
                            put "Try again"
                            points := points - 2
                        label "c" :
                            put "You are so close....NOT!!"
                            points := points - 2
                        label "d" :
                            put "YES!!"

                            points := points + 5
                            exit
                        label :
                            put "Chose one of the four choices"
                    end case

                end loop



            label 4 :                   %If bank is 4 then..
                finish := finish + 1

                put "Who was the last player to captain England before David Beckham?"
                put "(a) Martin Knowen"
                put "(b) Martin Keown"
                put "(c) Nomun Martin"
                put "(d) Nathan Martin"

                loop
                    get answer
                    case answer of
                        label "a" :
                            put "No"
                            points := points - 2
                        label "b" :
                            put "You got it right!!"

                            points := points + 5
                            exit
                        label "c" :
                            put "Not really"
                            points := points - 2
                        label "d" :
                            put ".........."
                            points := points - 2
                        label :
                            put "Choose the choices from the top"
                    end case

                end loop



            label 5 :                   %If bank is 5 then..
                finish := finish + 1

                put "Where was the 1998 World Cup held?"
                put "(a) Canada"
                put "(b) Germany"
                put "(c) France"
                put "(d) Britian"

                loop
                    get answer
                    case answer of
                        label "a" :
                            put "Try again"
                            points := points - 2
                        label "b" :
                            put "NO"
                            points := points - 2
                        label "c" :
                            put "Yes"
                            points := points + 5

                            exit
                        label "d" :
                            put "NO"
                            points := points - 2
                        label :
                            put "Choose one of the four choices"
                    end case

                end loop




            label 6 :                   %If bank is 6 then..
                finish := finish + 1

                put "Who scored England's dying seconds winner against Belgium in the 1990 World Cup?"
                put "(a) Evtushenko"
                put "(b) Pfaff"
                put "(c) David Beckham"
                put "(d) Pfaff Evtushenko"

                loop
                    get answer
                    case answer of
                        label "a" :
                            points := points - 2
                            put "No"
                        label "b" :
                            points := points + 5

                            put "Yes, You got it right"
                            exit
                        label "c" :
                            points := points - 2
                            put "NOOOOOO!"
                        label "d" :
                            points := points - 2
                            put "NO!!!!"
                        label :
                            put "please choose the choices from above"
                    end case

                end loop




            label 7 :                   %If bank is 7 then..
                finish := finish + 1

                put "What height and width is a football goal?"
                put "(a) 6inch by 8ft"
                put "(b) 8ft wide and 8ft tall"
                put "(c) 8yrds. and 8ft tall"
                put "(d) 10yrds. and 10ft tall"

                loop
                    get answer
                    case answer of
                        label "a" :
                            points := points - 2
                            put "No"
                        label "b" :
                            points := points - 2
                            put "Never!"
                        label "c" :
                            points := points + 5

                            put "Yea"
                            exit
                        label "d" :
                            points := points - 2
                            put "Nope"
                        label :
                            put "Please choose the choices from above"
                    end case

                end loop





            label 8 :               %If bank is 8 then..
                finish := finish + 1

                put "From 1980 - 1991 what NATIONAL team was Bryan Robson in?"
                put "(a) England"
                put "(b) France"
                put "(c) Canada"
                put "(d) Mexico"

                loop
                    get answer
                    case answer of
                        label "a" :
                            points := points + 5

                            put "Yup"
                            exit
                        label "b" :
                            points := points - 2
                            put "No"
                        label "c" :
                            points := points - 2
                            put "Not even"
                        label "d" :
                            points := points - 2
                            put "NEVER!!"
                        label :
                            put "Please choose the choices from above"
                    end case
                end loop





            label 9 :               %If bank is 9 then..
                finish := finish + 1

                put "Who did England Defeat to Win the 1966 World Cup?"
                put "(a) Germany"
                put "(b) East Germany"
                put "(c) South Germany"
                put "(d) West Germany"

                loop
                    get answer
                    case answer of
                        label "a" :
                            points := points - 2
                            put "close"
                        label "b" :
                            points := points - 2
                            put "Nah Bee!!"
                        label "c" :
                            points := points - 2
                            put "No"
                        label "d" :
                            points := points + 5

                            put "Yes, You are right"
                            exit
                        label :
                            put "Please choose the choices from above"
                    end case

                end loop


            label 10 :              %If bank is 10 then..
                finish := finish + 1

                put "Who broke his neck in the 1956 FA Cup Final?"
                put "(a) Bret Troff"
                put "(b) Bart Tartman"
                put "(c) Bret Trautmannt"
                put "(d) Bert Trautmann"

                loop
                    get answer
                    case answer of
                        label "a" :
                            points := points - 2
                            put "No"
                        label "b" :
                            points := points - 2
                            put "Ha! Tricked You"
                        label "c" :
                            points := points - 2
                            put "NO!"
                        label "d" :
                            points := points + 5
                            put "Yes!"
                            exit
                        label :
                            put "Please choose the choices from above"
                    end case

                end loop

        end case
        exit when finish = number_q         %When finish = to how many questions the user wants then the program will end
    end for


    put "And that's it"
    put ""
    put "You got, ", points, " Points"


    if points  5 and points  10 and points  20 and points  30 and points  40 and points  45 and points 