DISC 3371 - SPRING 2007 - Parks - EXAM ANSWERS
Click "View", then "SOURCE"

Nassi-Schneiderman Diagram
LOOP Drawing Tool
Loop Control Text:
 Statement
1
2
3
4
5
6
7
8
9
10

(1. 50 points). The table shown above to the LEFT is an HTML page that a professor uses to create sample Nassi-Schneiderman diagrams for loops. The prof places the appropriate 'loop control' text in the first textbox, then places the text for each 'statement' to be drawn inside the loop in the ten textboxes below. The eleven textboxes are in a form named p1_form. When the 'GO' button is clicked, a VBscript sub named p1 is executed. This sub creates a new page on-the-fly (as shown above to the right). The new page contains a borderless centered table. Each table row contains two cells. The first row contains the 'loop control' text across both columns. The second and subsequent rows contain a single blank space in the first column (50 pixels wide) and the 'statement' text in the second column. The second column for 'statement' text has a background color of "#bbbbbb". All text is bold faced and has font size="4". Do NOT display empty 'statement' textboxes. The resulting borderless table is placed inside a single cell table with a border size="5". Show NO HTML for the original page. Show only the VBScript code for p1.

 PI with 10,000 digits 


(2. 50 points).The HTML page shown to the far LEFT contains a form named p2_form; a texarea named ta; and a button labelled "GO" that when clicked executes the javascript function named p2. The textarea contains the value of PI with 10,000 digits (9,999 to the right of the decimal). When the "GO" button is clicked, the function p2 examines the all the digits to the right of the decimal. An HTML table is produced (see at LEFT) on-the-fly that shows:
1. each digit
2. the frequency of each digit (0 through 9) following the decimal place
3. a bar graph of the results by using 1 pixel file g1x1.gif. The width of each bar is the frequency of the digit DIVIDED by 10 and the height is 10 pixels.
4. the minumum and maximum frequencies and where they occurShow only the javascript code for p2.