Computer Science Canada help! Randomizing strings =\ |
Author: | seymournexus [ Tue Dec 14, 2004 2:49 pm ] |
Post subject: | help! Randomizing strings =\ |
%The random quiz %Randomly outputs one of the 21 availible questions %By Allen Lai %December 13, 2004 var answer, answer2, answer3, answer4, answer5, answer6, answer7, answer8, answer9, answer10, answer11, answer12, answer13, answer14, answer15, answer16, answer17, answer18, answer19, answer20, answer21 : int var choice : string var score : int := 0 var font, font2 : int put "Enter in a number 1 to 5." put "What are cool clothing?" put "1) Long Baggy Pants 2) Tight Pants 3) Sexy Pants 4) A quote 5) I don't know" get answer20 case answer20 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are correct." score := score + 1 exit label 5 : put "You are incorrect" score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What is Naruto?" put "1) An anime 2) Tight Pants 3) A girl 4) A robot 5) A movie" get answer21 case answer21 of label 1 : put "You are correct." score := score + 1 exit label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect" score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls put "Your final score is ", score, "." put "Your final percentage is ", score / 21 * 100, " percent." put "Do you want to play again? Yes to continue, no to exit." get choice if choice = "no" or choice = "No" or choice = "NO" or choice = "No" then exit end if end loop font := Font.New ("Verdana:20") font2 := Font.New ("Verdana:20") colorback(black) cls Font.Draw ("WELCOME TO ALLEN'S QUIZ!", 125, 200, font, 10) Font.Free (font) Font.Draw ("Created by Allen Lai!", 195, 170, font2, 6) Font.Free (font2) delay(4000) cls colorback (red) cls color (white) loop loop put "Enter in a number 1 to 5." put "Turing is:" put "1) a great programming language 2) a kind of car 3) a mathematician 4) a machine 5) some kind of girl" get answer case answer of label 1 : put "You are correct." score := score + 1 exit label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What are rabies:" put "1) a type of disease 2) a monster 3) the guy who invented the computer 4) C00L Clothes! 5) Who cares!" get answer2 case answer2 of label 1 : put "You are correct." score := score + 1 exit label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What is 2 * 2:" put "1) 1 2) 2 3) 3 4) 4 5) 5" get answer3 case answer3 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are correct." score := score + 1 exit label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What are robots:" put "1) Stupid machines 2) A computer 3) Cool Clothes 4) A machine programmed by humans 5) a police" get answer4 case answer4 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are correct." score := score + 1 exit label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "Who is George Bush:" put "1) Some stupid guy 2) An alien 3) President of the United States 4) A robot 5) Some inventor" get answer5 case answer5 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are correct." score := score + 1 exit label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "Define invent:" put "1) To copy another idea 2) To create something non-existant 3) Kentucky Fried Chickens 4) McDonald 5) An item" get answer6 case answer6 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are correct." score := score + 1 exit label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What is 8 * 9:" put "1) 76 2) 74 3) 72 4) 70 5) 68" get answer7 case answer7 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are correct." score := score + 1 exit label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What is 10 * 21:" put "1) 111 2) 240 3) 210 4) 70 5) 86" get answer8 case answer8 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are correct." score := score + 1 exit label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "Who in the following does not belong in the group:" put "1) Paul Martin 2) Mike Harris 3) Jean Chretian 4) John A. McDonald 5) Wendy" get answer9 case answer9 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are correct." score := score + 1 exit label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "Who is Britney Spears:" put "1) A singer 2) A dancer 3) An actor 4) A teacher 5) A goverment official" get answer10 case answer10 of label 1 : put "You are correct." score := score + 1 exit label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What is HTML:" put "1) An internet language 2) A type of computer code used to development application games 3) Hyper Text Markup Language 4) An ape 5) A goverment official" get answer11 case answer11 of label 1 : put "You are correct." score := score + 1 exit label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What is Windows Media Player:" put "1) A program used to output text 2) A program used to listen to music or watch videos 3) The world's first program 4) A type of fruit 5) Headphones" get answer12 case answer12 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are correct." score := score + 1 exit label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What is the squareroot of 36:" put "1) 3 2) 4 3) 5 4) 6 5) 7" get answer13 case answer13 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are correct." score := score + 1 exit label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What is the squareroot of 81:" put "1) 5 2) 6 3) 7 4) 8 5) 9" get answer14 case answer14 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are correct." score := score + 1 exit label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What is the square of 50:" put "1) 1000 2) 2500 3) 1250 4) 625 5) 312.5" get answer15 case answer15 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are correct." score := score + 1 exit label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What does not belong in the following:" put "1) Apes 2) Horse 3) Sheeps 4) Computer 5) Penguin" get answer16 case answer16 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are correct." score := score + 1 exit label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "What does PS7 stand for:" put "1) Power Supply 7 2) Photoshop 3) Photoshop7 4) Paintshop Pro 5) Pwnedsucker7" get answer17 case answer17 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are correct." score := score + 1 exit label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "Who is Allen Lai:" put "1) A guy 2) A smart guy 3) A very smart guy 4) A very very smart guy 5) All of the above" get answer18 case answer18 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are incorrect." score := score + 0 label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are correct." score := score + 1 exit label : put "Invalid Input." end case end loop delay (1000) cls loop put "Enter in a number 1 to 5." put "Who is the guy that invented the lightbulb:" put "1) Edison Chen 2) Thomas Edison 3) Edison Nobody 4) Edison Oi 5) Edison Lu" get answer19 case answer19 of label 1 : put "You are incorrect." score := score + 0 label 2 : put "You are correct." score := score + 1 exit label 3 : put "You are incorrect." score := score + 0 label 4 : put "You are incorrect." score := score + 0 label 5 : put "You are incorrect." score := score + 0 label : put "Invalid Input." end case end loop delay (1000) cls loop that's my coding, how do I make it so that the questions randomize it? I don't know how to use ranstrint, but if I did, i would change it to use randint. Thanks a lot. P.S. - I r n00bz |
Author: | Delos [ Tue Dec 14, 2004 3:13 pm ] |
Post subject: | |
1) Use [code] tags. 2) For that much code, attatch a file instead. 3) There is no such thing as "ranstrint". Unless of course you're thinking of creating it. 4) It is completely evident that you "r n00bz"...don't stress about it too much, you might pull a synapse. 5) On to your code... The simplest way to do this (simplest, not most efficient) would be to have all your questions and answers stored in variables before you start asking any questions. Next, you randomize an integer, and depending on the resultant number, display that question. [code] var qNum : int loop randint (qNum, 1, 21) if qNum = 1 then % display question 1 and all of its stuff... elsif qNum=2 %... end if end loop [/code] Something to that effect. Ok, so it doesn't really require you to store stuff before hand... Now for the more efficient way. Use procedures. With parameters. Parameters are your friends...parameters are good. Procedures Functions Processes by tony Arrays by tony Loops and For Loops by Cervantes Ifs by tony All those will help you in some way or another. |