DISC 3371 -- Fall 1999 -- Final Exam Answers -- Parks

1. (60 points) The HTML to create the following contains no frames -- just a four row table. The page's form is named eform; the six text boxes are named: r1, g1, and b1 in the second row; and r2, g2 and b2 in the third row.

Show a Web-Safe Color in the Background
Enter 0 to 255 for each color:
red green blue
Web Safe Color (hex)
red green blue

This code works! Try it. -- Click "View", then "Source" to see the source code

In a "web-safe" color scheme there are only 6 different color intensity values (00, 33, 66, 99, cc, and ff expressed in hexadecimal or 0, 51,102, 153, 204 and 255 in decimal) used for EACH of the three primary colors (red, green and blue). Thus there are only 216 possible color combinations (six for red, six for green and six for blue) for a "web-safe" color.

The user will enter three decimal values (0 to 255) in each of the three boxes on the second row. Then when the user clicks the button, a sub named nextc is called. This sub then does: (1) for each of the three decimal color values (0 to 255) the user enters in the second row (i.e., in r1, g1 and b1) find the nearest "web-safe" color in decimal; (2) place the corresponding hex values in r2, g2, b2, respectively; and finally (3) set the page's background color to this "web-safe" color.

"nearest" means the one of the six values closest to user's entry (either: 0, 51, 102, 153, 204 or 255, e.g., if the user entered 5,238 and 113 in the r1, g1 and b1 text boxes, the closest web-safe decimal values would be 0,255,102. These correspond to the hexadecimal values "00", "ff", and "66", which would be displayed in the text boxes r2, g2 and b2. The background would then be set to "#00ff66".

nearest should be a function referenced by nextc. The function is passed one argument -- the user's decimal color entry. The function should return the nearest hexadecimal color expressed as a two-byte string.

Show NO HTML. Show only the VBScript for nextc and nearest. Do not edit the user's input (assume they will enter the values 0 to 255 in each box on the second row).

2. (40 points)

World-Wide-Wanna-be-a-geek?
Answer this question:
Order the following programming languages by of their date of creation.
Oldest Newest
1.                
2.                
3.                
4.                
Click here to see the working page!

The page above is displayed with a three frame frameset organized into rows. The question requires the user to order the languages by age (i.e., in each of the four rows the user would click one radio to indicate the relative age of the language). This second frame also contains a hidden field named answer_string which contains the value "3241". This string stores the correct answer (i.e., oldest is the third answer, then the second, then the fourth, then the first).

The user will choose four radio buttons in the second frame (note that only one radio is chosen in each row and only one is chosen in each column) and then click the button in the third frame. The HTML will then call a sub named gradeit. This sub rewrites the second frame on-the-fly. This new page contains two parts: (1) If the user radio selections correspond to the correct answers stored in answer_string, then display "YOU WIN" else display "YOU LOSE"; and (2) display the correct answers (the words) and the user's answers (the words) in five-row two-column table. The first row contains the two column headings: "Correct Order" and "Your Answer". The last four rows contain the correct and user answers (answers are ordered oldest first). Assume that only one radio is chosen in each row and only one is chosen in each column -- do not test for this condition. Show no HTML. Show only the VBScript code for gradeit.