DISC 3371 Final Exam SPRING 2006 Parks ANSWERS

When the button labelled "GO 1" is pressed, execute a sub named p1. Fill each of two 20 element arrays named x and y with random integers between 1 and 400. Then create a graph of these twenty pairs inside a SPAN block inside a table cell. This span block is named fred.

Calculate the average value of the x and y values. Place a 5 by 5 pixel image at the location of each pair where the value of x defines the number of pixels from the left edge of the cell and the y value defines the distance from the top of the cell. Use a single pixel gif file to make the 5x5 squares. If the value of any y is greater than the average y use the file named "green1x1.gif" to create the 5x5 image otherwise use the "black1x1.gif" file (these two gif files are 1 pixel by 1 pixel in size).

Additionally, place the average x and y values in span blocks with id ax and ay, respectively.

  This is the the fred SPAN block

Averages: X= Y=

Show only the vbscript code for p1. DO NOT create the vertical and horizontal axes as is shown above. Show NO HTML.

2. (40 points) Assume the x and y arrays as above are available in javascript. Create an XML file according to the following DTD:

<?xml version="1.0"?>
<!DOCTYPE randomnumbers [ <!ELEMENT randomnumbers (xvalue, yvalue, xminusy, xplusy, xtimesy)
<!ELEMENT xvalue (#PCDATA) >
<!ELEMENT yvalue (#PCDATA) >
<!ELEMENT xminusy (#PCDATA) >
<!ELEMENT xplus (#PCDATA) >
<!ELEMENT xtimesy (#PCDATA) >
]>

When the "GO 2" button is pressed, execute a javascript function named p2. This javascript function creates the XML file described above by using the x for the xvalue and y for the yvalue values as discussed in problem 1. Additionally the function calculates three more values for each x,y pair:

  1. the difference ( x - y) tagged as xminusy
  2. the sum (x + y) tagged as xplusy
  3. the product (x * y ) tagged as xtimesy

Display the resulting XML file in a DIV block named alice.

Show only the javascript for p2. Assume the x and y are already created (i.e., don't rewrite the code from problem #1 to generate the random values). Show NO HTML.


  

This is the alice DIV block