Final Exam
Cosi 2a/Aut01
Instr: Tim Hickey
This exam has six questions and is worth 30 points.
There is also a 1 point extra credit question.
The exam is open book and open notes.
You have three hours to complete the exam.
I. Binary,Hex, and Dotted Decimal Numbers [3 pts]
- Convert 225.255.33.46 to binary
- Convert 225.255.33.46 to hexadecimal
- Convert ABCDEF from hexadecimal to dotted decimal
II. HTML [6 pts]
Write the HTML for the following webpage.
Note that this page contains a form which will be used to
send data to the servlet in the next problem.
III. SXML [6 pts]
Write the SXML for a servlet that processes the data from the previous form.
If the user types in the correct password (which is "waycool"), then
the servlet will generate the following page (which includes a count of how
many people successfully completed the survey with the right password).

The servlet also sends two email messages:
- the first to your email address from "cs2a@cs.brandeis.edu"
giving the current date and time, and the user's answers to the survey questions
about Sex and Political Party, but not the user's email address
- the second to the user, from your email address,
thanking them for participating in the
survey, and giving them the date and time that the survey was taken.
If the user types in
the wrong password, then the following page should appear:

IV. Scheme Tracing[6 pts]
Trace the evolution of the following Scheme expressions
-
(- (+ (- (+ (- 10 2) 3) 4) 5) 6)
-
(define (f n x p)
(if (= n 0) x
(if (odd? n)
(f (- n 1) (* x p) p)
(f (/ n 2) x (* p p)))))
(f 10 1 2)
-
(define (g x)
(if (< n 3) 1 (+ (g (- n 1)) (g (- n 2))))))
(g 5)
V. Applets [6 pts]
Write the Scheme code for the following applet. It asks the user for the principal "P"
the interest "I" and the desired monthly payment "M" and then figures out about how many
months "N" the user will have to pay to retire the loan. The formula for "N" is given below:
First we compute
F= 1 + (I/1200.0)
Then we compute N using the rather messy formula:
N = - log(1 - (P/M)*(F-1)) / log(F)
Finally, you may want to get rid of the decimal part
by rounding N to the nearest integer.
Note that the scheme function (log x) takes the log of x,
and the function (round x) rounds x to the nearest whole number.
Also, the applet should define a "quit" item in the "File" menu which closes
the window, and an "about" item in the help menu. Clicking the about item,
pops up a window with your name and the date and a "close" button, which closes
that window.
VI. Circuits[3 pts]
Trace through the following circuit for each of the following three input examples:
| x | y | z | u | v |
| T | T | T | ___ | ___ |
| F | T | F | ___ | ___ |
| F | F | F | ___ | ___ |
Extra Credit [1 pt]
Work out the two rows of the truth table (below) for the following circuit:
and draw a picture showing which wires are connected and
which are disconnected in each of these two cases.