Answer all questions. One hour and 20 minutes.
Return both questions and answers.
Name: _________________________________________ Grade: __________________
(1) [10 points] Write a Javascript program to display a new random quote every second. On loading, the page displays:
The random quote is displayed in a text field and is randomly changed every second. For example, one second later, it may become:
Write your program to produce output as close to the screens above as possible.
Hints: use the function Math.random to get a random number from 0 to 1.0. Use the function Math.floor(x) to get the integer part (the floor) of the number x.
The first half of the solution is done for you:
<html>
<head>
<title>Random Quote</title>
<script language=Javascript>
<!-- Hide scripts from older browsers.
var UPDATE_PERIOD = 1000;
var quotes = new Array("I am hungry!!",
"Pass the burgers!!",
"CGI is fun.",
"Give me Perl or give me Java.",
"CGI.pm is good for your health.",
"You will meet a CGI expert and fall in love today.",
"XML is not the only markup language.",
"C++ is good!!");
....
' your work here.
(2) [15 points] Consider the following table stored in the DSN "temp".
School(SchoolId, SchoolName, SchoolURl, District, Rating)
An example of an instance of the table:
SchoolId | SchoolName | SchoolURL | District | Rating |
1 | Southwestern | http://southwesternhigh.edu | Richardson | 5 |
2 | Central Park | http://centralparkhigh.edu | Richardson | 4 |
3 | Harris Memorial | http://hmhigh.edu | Richardson | 4 |
4 | Jone's Memorial | http://jonesmemoral.edu | Homer | 2 |
5 | Katy | http://katyhighschool.edu | Homer | 3 |
6 | Richardson's First | http://richardson1st.edu | Richardson | 3 |
7 | Richardson's Second | http://richardson2nd.edu | Richardson | 4 |
8 | Garfinkel | http://garfinkel.edu | Norris | 5 |
Write an ASP program t2aq2.asp (Cold Fusion program not acceptable) to display all schools in the order of district and school name. The format must be identical to the following screen.
There are three columns in the HTML table: rating, school name and district. There is one row per district in the HTML table. Within a row, each school and its rating are displayed in one line.
(3) [7 points] Consider the following document, which is supposed to be XML.
<?xml version="1.0" ?>
<?xml-stylesheet href="t2aq4.css" type="text/css"
?>
<!DOCTYPE chapter SYSTEM "t2aq4.dtd">
<chapter>
<author name=yue>
<title>Linear Equation</title>
<p>
A linear equation
can be solved easily.
<example
num="1">x + 5 > y; 2*x -10 < z </example>
<example
num="2">x + y = 10</example>
<p>
A linear equation
can be ...
</chapter>
(a) It is not well-formed. Correct the file to make it well-formed. Note that only the tag author is empty.
(b) Give a minimal DTD for the corrected XML file.