Practice Final CS2a/Aut06
I. Binary, Dotted Decimal, Hexadecimal
- Convert the dotted decimal number 192.168.37.81 to a 32 bit binary number
- Convert the dotted decimal number 192.168.37.81 to an 8 character hexadecimal number
- Convert ACE16 from hexadecimal to binary
- Convert ACE16 from hexadecimal to decimal
answers
II. CMOS
Consider the following CMOS circuit
The P gates have been labelled T1, ..., T5 and the N gates have been labelled
S1 through S5. There are two input wires (A,B) and two intermediate wires (C,D) and
one output wire (E).
- Which gates lie on the path between D and power?
- Which gates lie on the path between D and ground?
- Which gates are controlled by the charge on C?
- Which gates are controlled by the charge on B?
- For C to be connected to power, gate T1 must be connected.
What must happen for D to be connected to power? (i.e. which gates must be connected)
- Similarly, what must happen for E to be connected to ground? (i.e. which gates must be connected)
There are four possible choices for the input values of A and B. For each choice indicate the values of
the intermediate wired (C,D) and the output wire (E) and also indicate which of the gates are connected (CONN)
and which are disconnected (DISC) in the following table. You should label C,D,E with 0 (connected to ground) or
1 (connected to power) or SHORT (connected to both power and ground) or FLOATING (connected to neither power
nor ground. The latter two should only occur if the circuit is improperly designed.
|
A
|
B
|
T1
|
S1
|
C
|
T2
|
S2
|
T3
|
S3
|
D
|
T4
|
S4
|
T5
|
S5
|
E
|
| 0 | 0 | CONN | DISC | 1 | | | | | | | | | | |
| 0 | 1 | | | | | | | | | | | | | |
| 1 | 0 | | | | | | | | | | | | | |
| 1 | 1 | | | | | | | | | | | | | |
The answer graphically or
as text
III. SQL and Database-backed servlets
A. Creating a table
Write a servlet that creates a database table that could be used for registering site visitors. It should have four
fields: their email address, their password, what year they joined, and their sex. After creating the table
it should generate a response page that shows the result of the query. It should NOT be password protected.
The response page should be a simple HTML page with title "ADMIN".
ANSWER:
see source or
run it and create the database table.
(NB: This will generate an error unless you first delete the
table using pf3d.servlet).
B. Storing information in the table
Write a servlet that adds a users registration to the table. You can assume that someone else has written
an HTML page that asks the user for their email address (E), their password (P), and their sex (S). You should
write a servlet that takes that information and adds a row to the table. Use 2006 for the year they joined.
(This assumes the administrator will change that value in the servlet every January 1st!). The servlet should
then generate a response page showing the result of the query that inserted the data into the database.
ANSWER:
see source or
run it and insert a row into the table.
Also run the dbtest.servlet program to
generate a bunch of rows in the table.
C. Selecting information from the table
Assume that someone has written an HTML page that ask the user for a year (Y) and a sex (S). Your servlet should
take that information from the servlet parameters and use it to generate a table of all users on the given sex (S)
who joined BEFORE the given year (Y). It should display that information in a table.
ANSWER:
see source or
run it and select some rows from the table.
D. Reseting the table
Write a servlet, which is password protected, and which generates a response page containing all of the rows
of the table. It should also drop the table. This would be called for example if one was shutting down a web
service but wanted one last printout of the users.
ANSWER:
see source or
run it and remove the table from the database.