ANSWER PAGE
MIDTERM EXAM 10/21/98
DISC 3371MIDTERM
ParksFall 98
Grade Distribution:90-10026
80-8927
70-7931
60-6926
50-5929
40-4927
30-3921
20-2943
10-1912
0-98
Average=55

1. (40 points) Given the following page:

ENTER: UserID Date-of-Birth: Month Day Year

My New Password is:
The first field is named userid; the second field is named "mon", the third field is named "day", the fourth field is named "yr", the last field is named "newpass" and the button is named gmp. The maximum length of the userid is 8 bytes. The three date fields can contain up to 2 numeric characters each. Show only the VBScript (no HTML) so that when the user clicks the button named Generate My Password, a new password is created for the user and displayed in the text box labeled My New Password is: The programs should check the following and display an error message to the user describing the mistake if any condition is violated.

If any data entry violations are detected, display an error message to the user. If no errors are detected, then create a password for the user by:

  1. The first two bytes of the new password are the second and third bytes of the userid
  2. The third and fourth bytes of the new password are the value of the yr field entered by the user
  3. The fifth byte of the new password is the second digit of the mon field entered by the user
  4. The sixth byte of the new password is the second digit of the day field entered by the user

After the new password is created, the program should display the new password in the text box named newpass.


ANSWER: Try out the boxes and button above. They work.
Click "View Source" to see the code.


2. (60 points) Given an HTML page that contains:

  1. <form name="fname">
  2. <text area name="ta" rows="12" cols="50"></textarea>
  3. <input type="button" value="GO" onclick="fred">

Show the VBScript necessary to:

  1. When the button GO button is clicked, the program takes the text entered into the field named ta and stores each word as an element in an array named w. The array w should be able to hold up to 200 words. Words in the text are assumed to be separated by a single space (i.e., do NOT check for 2 or more consecutive spaces).
  2. After the text has been separated into words, for each word in w, a function named addy should be called which adds the character "y" to each word if the word is longer than 3 characters. (e.g., the word "LUNCH" would become "LUNCHy, "TOE" stays as "TOE")
  3. After the words have been checked and modified, clear the page and write an HTML page that shows all the words stored in w. Separate each word with a <BR> tag.


ANSWER: From the problem statement above, the HTML code described will produce a textarea and a button as shown below.

Click the "GO" button above to watch it work.
Click "View Source" to see the VBScript code that answers this second question.

Three other exam variations were given. One like the one above but with different names. Two others use sentences rather than words