  Spring Semester 2002

This exam has two parts:

1. Solve the problem below, turn your solution at the end of time.
2. Take your solution with you, implement it, post it on-line within four days.

The second part is optional. Your grade for the exam will be the average of the grade for part  and part . The due date for part  is Monday March 4, 2002, at the end of the day (11:59pm).

The exam is open-book, open-notes. Here's the problem; consider the following Perl program:

```#!/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";
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"; ```
Here's how it works:
```frilled.cs.indiana.edu%./quiz
Question 1: What is -26 + -25?
Very good, that was the answer.
Question 2: What is -41 + 20?
Very good, that was the answer.
Question 3: What is 38 + 26?
Very good, that was the answer.
Question 4: What is 22 + 15?
Very good, that was the answer.
Question 5: What is -27 + 29?
Sorry. The right answer was: 2
Question 6: What is 0 + -11?
Very good, that was the answer.
Question 7: What is -4 + -20?
Very good, that was the answer.
Question 8: What is 11 + 33?
Very good, that was the answer.
Question 9: What is 30 + 25?
Sorry. The right answer was: 55
Question 10: What is -27 + 46?
Very good, that was the answer.
End of quiz. Thanks for your interest.
Your score is: 8 out of 10
frilled.cs.indiana.edu%``` Implement a functionally equivalent version of this program using PHP or CGI with Perl.

Things to keep in mind:

• it's up to you what you choose to work with (PHP or CGI)
• if you choose PHP it's up to you if you use sessions or not
• if you choose CGI with Perl it's up to you if you choose `CGI.pm` or not
• your goal is to have a web version of this program working

` LH102 5:45pm-7:00pm Feb 28, 2002 `