Computer Science Canada I need help with my program, please help |
Author: | chadjohnson [ Fri Jan 20, 2006 9:38 pm ] |
Post subject: | I need help with my program, please help |
Ok. I am supposed to make this quiz for clss but the problem is that i need some basic functions/arrays/procedures. I have none in my program so im asking plz if anyone could make my code smaller with functions/arrays/procedures. Plz im desperate.Heres my code. functions/arrays/procedures. %loop to redo quiz loop % program description locate (10, 12) put "This program is a quiz about Cd/DVD discs and drives. At the end" locate (11, 12) put "of the quiz it will output the number of correct" locate (12, 12) put "answers and the number of incorrect answers" locate (13, 12) put "along with the percent of correct answers." locate (16, 12) put "Note:Lower Case only,Capitals will be considered invalid" % var dec var test : string var answer : string var correct_ans : int := 0 var incorrect_ans : int var percent : real % One try multiple choice questions % Question 1 % Display Q and possible Answer delay (100) cls locate (10, 12) put "You have 1 try to answer this question" locate (12, 12) put "Which one of these companies does not make CD/DVD Drives?" locate (13, 12) put "a)Sony" locate (14, 12) put "b)HP" locate (15, 12) put "c)Intel" locate (16, 12) put "d)Sanyo" % loop to check for validity loop put repeat (" ", 11) .. get answer exit when answer = "a" or answer = "b" or answer = "c" or answer = "d" put repeat (" ", 11), "The answer you have put is invalid, please put another anwer" end loop if answer = "c" then put repeat (" ", 11), "That is correct!" correct_ans := correct_ans + 1 % put picture else put repeat (" ", 11), "That is incorrect,the correct answer is C" % put picture end if delay (500) cls % Question 2 % display Q and possible Ans locate (10, 12) put "You have 1 try to answer this question" locate (12, 12) put "Why can a Blu-Ray disc hold more data than a CD?" locate (13, 12) put "a)The Blu-Ray Disc has a different colour bottom than the other" locate (14, 12) put "b)The Blu-Ray Discs laser is smaller" locate (15, 12) put "c)The Blu-Ray Disc spins at a faster speed" locate (16, 12) put "d)The Blu-Ray is thicker" % loop to check for validity loop put repeat (" ", 11) .. get answer exit when answer = "a" or answer = "b" or answer = "c" or answer = "d" put repeat (" ", 11), "The answer you have put is invalid, please put another anwer" end loop if answer = "b" then put repeat (" ", 11), "That is correct!" correct_ans := correct_ans + 1 % put picture else put repeat (" ", 11), "That is incorrect,the correct answer is B" % put picture end if delay (500) cls % Question 3 % display Q and possible Ans locate (10, 12) put "You have 1 try to answer this question" locate (12, 12) put "A Peripheral is" locate (13, 12) put "a)Any hardware under the control of the CPU" locate (14, 12) put "b)Software for disk management" locate (15, 12) put "c)Optional extras for computers" locate (16, 12) put "d)A storage device" % loop to check for validity loop put repeat (" ", 11) .. get answer exit when answer = "a" or answer = "b" or answer = "c" or answer = "d" put repeat (" ", 11), "The answer you have put is invalid, please put another anwer" end loop if answer = "a" then put repeat (" ", 11), "That is correct!" correct_ans := correct_ans + 1 % put picture else put repeat (" ", 11), "That is incorrect,the correct answer is A" % put picture end if delay (500) cls % Question 4 % display Q and possible Ans locate (10, 12) put "You have 1 try to answer this question" locate (12, 12) put "A letter that usually represents the floppy drive" locate (13, 12) put "a)C Drive" locate (14, 12) put "b)E Drive" locate (15, 12) put "c)B Drive" locate (16, 12) put "d)A Drive" % loop to check for validity loop put repeat (" ", 11) .. get answer exit when answer = "a" or answer = "b" or answer = "c" or answer = "d" put repeat (" ", 11), "The answer you have put is invalid, please put another anwer" end loop if answer = "d" then put repeat (" ", 11), "That is correct!" correct_ans := correct_ans + 1 % put picture else put repeat (" ", 11), "That is incorrect,the correct answer is D" % put picture end if delay (500) cls % Question 5 % display Q and possible Ans locate (10, 12) put "You have 1 try to answer this question" locate (12, 12) put "If you want to format a floppy disk the write-protect slide must be" locate (13, 12) put "a)Right Clicked" locate (14, 12) put "b)Open" locate (15, 12) put "c)Closed" locate (16, 12) put "d)Double Clicked" % loop to check for validity loop put repeat (" ", 11) .. get answer exit when answer = "a" or answer = "b" or answer = "c" or answer = "d" put repeat (" ", 11), "The answer you have put is invalid, please put another anwer" end loop if answer = "c" then put repeat (" ", 11), "That is correct!" correct_ans := correct_ans + 1 % put picture else put repeat (" ", 11), "That is incorrect,the correct answer is C" % put picture end if delay (500) cls % Question 6 % display Q and possible Ans locate (10, 12) put "You have 1 try to answer this question" locate (12, 12) put "The average amount of GB a DVD can hold is" locate (13, 12) put "a)3.8" locate (14, 12) put "b)4.7" locate (15, 12) put "c)5.1" locate (16, 12) put "d)2.4" % loop to check for validity loop put repeat (" ", 11) .. get answer exit when answer = "a" or answer = "b" or answer = "c" or answer = "d" put repeat (" ", 11), "The answer you have put is invalid, please put another anwer" end loop if answer = "b" then put repeat (" ", 11), "That is correct!" correct_ans := correct_ans + 1 % put picture else put repeat (" ", 11), "That is incorrect, the correct answer is B" % put picture end if delay (500) cls % 3 try multiple choice questions % question 7 % display Q and possible Ans locate (10, 12) put "You have 3 tries to answer this question" locate (12, 12) put "The average diameter of a compact disc is" locate (13, 12) put "a)120mm" locate (14, 12) put "b)150mm" locate (15, 12) put "c)110mm" locate (16, 12) put "d)116mm" locate (17, 12) put "e)135mm" % counter to tell user number of tries left for decreasing counter : 3 .. 1 % loop to check for validity loop put repeat (" ", 11) .. get answer exit when answer = "a" or answer = "b" or answer = "c" or answer = "d" or answer = "e" put repeat (" ", 11), "The answer you have put is invalid, please put another anwer" end loop if answer = "a" then put repeat (" ", 11), "That is correct!" correct_ans := correct_ans + 1 exit % put picture else put repeat (" ", 11), "That is incorrect" put "you have ", counter - 1, " tries left." end if end for delay (500) cls % question 8 % display Q and possible Ans locate (10, 12) put "You have 3 tries to answer this question" locate (12, 12) put "DVD+RW DVDs enable you to" locate (13, 12) put "a)Burn at a faster speed" locate (14, 12) put "b)Watch movies with better quality" locate (15, 12) put "c)Clean your DVD Drive" locate (16, 12) put "d)Hold more data" locate (17, 12) put "e)Rewrite files" % counter to tell user number of tries left for decreasing counter : 3 .. 1 % loop to check for validity loop put repeat (" ", 11) .. get answer exit when answer = "a" or answer = "b" or answer = "c" or answer = "d" or answer = "e" put repeat (" ", 11), "The answer you have put is invalid, please put another anwer" end loop if answer = "e" then put repeat (" ", 11), "That is correct!" correct_ans := correct_ans + 1 % put picture exit else put repeat (" ", 11), "That is incorrect" put "you have ", counter - 1, " tries left." end if end for delay (500) cls % fill in the blanks % question 9 % display Q locate (10, 12) put "Fill in the blank, you have 1 try to answer" locate (12, 12) put repeat (" ", 15), "question" put repeat (" ", 11) .. get answer if answer = "ans" then put repeat (" ", 11), "That is correct!" correct_ans := correct_ans + 1 % put pic else put repeat (" ", 11), "That is incorrect" end if delay (500) cls % question 10 % display Q locate (10, 12) put "Fill in the blank, you have 1 try to answer" locate (12, 12) put repeat (" ", 15), "Video Disc is what DVD stands for" put repeat (" ", 11) .. get answer if answer = "digital" then put repeat (" ", 11), "That is correct!" correct_ans := correct_ans + 1 % put pic else put repeat (" ", 11), "That is incorrect, the correct answer is Digital" end if delay (500) cls % question 11 % display Q locate (10, 12) put "Fill in the blank, you have 1 try to answer" locate (12, 12) put repeat (" ", 15), "question" put repeat (" ", 11) .. get answer if answer = "ans" then put repeat (" ", 11), "That is correct!" correct_ans := correct_ans + 1 % put pic else put repeat (" ", 11), "That is incorrect" end if delay (500) cls % question 12 % display Q locate (10, 12) put "Fill in the blank, you have 1 try to answer" locate (12, 12) put repeat (" ", 15), "question" put repeat (" ", 11) .. get answer if answer = "ans" then put repeat (" ", 11), "That is correct!" correct_ans := correct_ans + 1 % put pic else put repeat (" ", 11), "That is incorrect" end if delay (500) cls incorrect_ans := 12 - correct_ans percent := (correct_ans / 12) * 100 % display results locate (10, 12) put "The number of answers that you got correct were ", correct_ans, " ." locate (11, 12) put "The number of answer you got incorrect were ", incorrect_ans, " ." locate (12, 12) put "The percentage that you have recieved on this quiz is ", percent : 5 : 2, " %." delay (10000) cls % ask user if they want to take the test again put "Type anything to take the test again, else type no?" get test % exit loop exit when test = "no" % end loop end loop put "Thank you for taking the test" |