MIS 3371 PARKS MIDTERM SPRING 2010

My 30-Second
"Tell Me About Yourself"
Speech?

My Past


My Accomplishments.


My Future

1. (50 points) The six textareas to the left are in a form named p1form. When the "Evaluate My Speech Time" button is clicked, a vbscript sub named p1 is executed. The sub p1: (a) retrieves the contents of the six textareas; (b) counts the number of words in each textarea; (c) assuming that a person speaks at about 155 words per minute (or 2.583 words per second), the sub calculates how many seconds it takes to speak the words in each textarea. The sub will produce a seven row - two column table (shown below) that contains:
1. six rows corresponding to the six textareas (one through six). Each row contains:
    (a) In column 1, the number of words in the textarea.
    (b) In column 2, the number of seconds required to speak the text in the textarea
        (i.e., column 1 divided by 2.583)
2. the seventh (last) row contains:
    (a) In column 1, the word "TOTAL TIME"
    (b) In column 2, the number of seconds required to speak the text in all the textareas
        (i.e., the total number of words divided by 2.583)
 
The sub displays the table in a DIV block with id="e_out".

The table shown to the right contains the desired answer for this problem    
as it would appear in the DIV block with id="e_out".

Show NO HTML.

Show ONLY the vbscript code for the sub named p1.

This is
the DIV
block with
id="e_out"
LetterFrequency
Graph
a 8.167%
This
is
the
DIV
block
with
id="g"

b 1.492%
c 2.782%
d 4.253%
e 12.702%
f 2.228%
g 2.015%
h 6.094%
i 6.966%
j 0.153%
k 0.772%
l 4.025%
m 2.406%
n 6.749%
o 7.507%
p 1.929%
q 0.095%
r 5.987%
s 6.327%
t 9.056%
u 2.758%
v 0.978%
w 2.360%
x 0.150%
y 1.974%
z 0.074%
2. (50 points) The table to the left shows the frequencies of occurence of the lettrs "a" through "z" in English language texts.
  • Assume an array of 26 elements named f has been created in a javascript function named p2. This array has been initialized and contains the values shown in the second column of the table with no "%" signs (i.e., f[0]=8.167, f[1]=1.492, f[2]=2.782, ... , f[25]=0.074). A second array named alpha also has 26 elements and has been initialized to the letters of the alphabet
    (i.e., alpha[0]="a", alpha[1]="b",...,alpha[25]="z").
  • The third column of the table has a rowspan="26".
  • There is initially a DIV block with id="g" in the third column cell.
  • This DIV initially contains a button labelled "Execute p2" that executes the javascript function named p2 when clicked.
    [The button is not visible on the printed exam -- the answer (i.e., the table) is shown instead]
  • The function p2:
    1. creates a borderless table with 26 rows and two cells per row;
    2. the first cell in each row contains a letter from the alpha array. The first row has an "a" in the first column (from alpha[0]); the second row has a "b" in the first column (from alpha[1]),...,the last row has a "z" in the first column (from alpha[25]);
    3. the second cell in each row contains:
      1. an image tag with src="black1x1.gif";
      2. the height attribute of the gif image in each row is set to 16;
      3. the width attribute of the gif image is found by:
            width = parseInt ( f[i] * 10.0 );
        where the array value f[i] is the frequency of the ith letter (i = 0 to 25) (e.g., the width of the gif image for the first row would be: parseInt(8.167 * 10.) or 81; the second row's gif image would be: parseInt( 1.492 * 10.0) or 14, etc.
    4. find the letter with the maximum frequency and use the image file named "gray1x1.gif" for the src attribute ONLY on the row that contains this maximum frequency. Otherwise use src="black1x1.gif" as stated above.

Show NO HTML.

Show only the javascript for p2.