![]() |
![]() Spring Semester 2002 |
Please write your name or username here: __________________________________
This exam has two parts:
The exam is open-book, open-notes. Here's the problem; consider the following Perl program:
Here's how it works:#!/usr/bin/perl $count = 1; $correct = 0; print "Welcome to the Addition Quiz. \n"; while ($count <= 10) { $one = int(rand(100) - 50); $two = int(rand(100) - 50); print "Question $count: What is $one + $two?\n"; print " Answer: "; $answer = <STDIN>; if ($answer == $one + $two) { $correct += 1; print "Very good, that was the answer.\n"; } else { print "Sorry. The right answer was: ", ($one + $two) , "\n"; } $count += 1; } print "End of quiz. Thanks for your interest.\n"; print "Your score is: $correct out of ", ($count - 1), "\n";
frilled.cs.indiana.edu%./quiz Welcome to the Addition Quiz. Question 1: What is -26 + -25? Answer: -51 Very good, that was the answer. Question 2: What is -41 + 20? Answer: -21 Very good, that was the answer. Question 3: What is 38 + 26? Answer: 64 Very good, that was the answer. Question 4: What is 22 + 15? Answer: 37 Very good, that was the answer. Question 5: What is -27 + 29? Answer: -2 Sorry. The right answer was: 2 Question 6: What is 0 + -11? Answer: -11 Very good, that was the answer. Question 7: What is -4 + -20? Answer: -24 Very good, that was the answer. Question 8: What is 11 + 33? Answer: 44 Very good, that was the answer. Question 9: What is 30 + 25? Answer: 65 Sorry. The right answer was: 55 Question 10: What is -27 + 46? Answer: 19 Very good, that was the answer. End of quiz. Thanks for your interest. Your score is: 8 out of 10 frilled.cs.indiana.edu%
Things to keep in mind:
CGI.pm
or not
Graduate Standing:
General notes:
LH102 5:45pm-7:00pm Feb 28, 2002