[8 pts] How would of the following base-10 numbers be represented in an eight-bit two's-complement system?
a. | 80 |
b. | −1 |
c. | −120 |
a. | 80: | 01010000 |
b. | −1: | 11111111 |
c. | −120: | 10001000 |
[10 pts] Complete the below XHTML file so that when viewed in a browser the page appears as follows. (Notice how the two columns are aligned.)
Tests
Thu 20 Sep Exam 1 Thu 1 Nov Exam 2 Wed 5 Dec Final <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Test dates</title> </head> <body> <h1>Tests</h1> <table> <tr><td>Thu 20 Sep</td><td>Exam 1</td></tr> <tr><td>Thu 1 Nov</td><td>Exam 2</td></tr> <tr><td>Wed 5 Dec</td><td>Final</td></tr> </table> </body> </html>
[12 pts] Suppose we have the following HTML form, which displays two text fields and a button.
<form method="post" action="hyp.php"> <p>2006 data: <input type="text" name="year1" /></p> <p>2007 data: <input type="text" name="year2" /></p> <p><input type="submit" value="Compute" /></p> </form>
Complete the following PHP file so that it displays a histogram for the two integers entered; that is, it should list each year followed by a row of asterisks corresponding to the number entered by the user. For example, if the user enters 5 in the blank labeled 2006 and 8 in the blank labeled 2007, the PHP script should send to the browser an XHTML page that is displayed as follows.
2006: *****
2007: ********
You may assume that both numbers entered by the user are positive integers.
<?php import_request_variables("pg", "form_"); ?> <html> <head> <title>Histogram</title> </head>
<body> <b><?php</b><i> for($yr = 1; $yr <= 2; $yr++) { $year = 2005 + $yr; $num = $_POST["year$yr"]; echo "<p>$year: "; for($i = 0; $i < $num; $i++) { echo "*"; } echo "</p>\n"; } </i><b>?></b> </body> </html>
[8 pts] In class, we imagined a database for a library, containing the following three, with columns as listed.
|
|
|
Write an SQL query that lists the names of all books ever checked out
by anybody called Ishmael.
SELECT title FROM Holdings, Checkouts, Patrons WHERE Holdings.call_number = Checkouts.call_number AND Checkouts.student_id = Patrons.student_id AND Patrons.name = 'Ishmael'
[10 pts] Suppose Hendrix's Financial Aid office has hired you to design a database to store information about students' scholarships. For each scholarship, they want to store the recipient's student ID, the recipient's name, the scholarship title, the scholarship source, the contact address for the source, the scholarship amount, and the scholarship's GPA requirement. Note that sometimes multiple students will receive the same scholarship.
What tables will you suggest they create, and what columns would be in each table?
[8 pts] At right is a map of the distribution of ZIP codes within the United States. As you see, ZIP codes in Alaska range from 99500 to 99999. Design a regular expression that accepts only five-digit ZIP codes for Alaska.
[8 pts] Design a regular expression that accepts only strings of letters that begin with a capital letter followed by one or more lower-case letters.
[8 pts] Between 1909 and 1976, what was required for a U.S. citizen to obtain a U.S. copyright on a book?
The book had to be registered with the U. S. Copyright Office, a copy sent to the Library of Congress, and the book had to bear the copyright symbol © with the year of copyright and the copyright claimant.
[8 pts] In order to support the notion of browser sessions, how does PHP normally distinguish browsers? Be specific.
To start a session, the server generates and stores a random number, which is sent to the browser as a cookie. The browser then stores this cookie and sends it back with each subsequent request to the server; the server can then correlate this to determine the browser.