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]


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:

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

  1. (- (+ (- (+ (- 10 2) 3) 4) 5) 6)
    
  2. (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)
    
  3. (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:

xyzuv
TTT______
FTF______
FFF______


Extra Credit [1 pt]

Work out the two rows of the truth table (below) for the following circuit:

xyzw
TTT___
FTF___

and draw a picture showing which wires are connected and which are disconnected in each of these two cases.