DISC 3371 MIDTERM 4-5:30 MW Spring 2000 Parks Answers (revised 3/27/2000)

1. (60 points) A web page to collect a user's movie review contains: (1) a single form named movie_review_form; (2) a single textarea named ta containing 10 rows and 40 columns; and (3) a single button named but1 which is labelled "GO". The user will enter text (their opinion of a movie) in the textarea box and then click the "GO" button. This event will cause a sub named movie to be executed. This sub has two arrays: (1) a ten element array named words that contains the strings: "great"; "good"; "excellent"; "enjoy": "best"; "boring"; "bad"; "awful"; "waste"; and "terrible"; and (2) a ten element array named wc which should be initialized to zero. The sub should: (1) retrieve the user's text from the textarea box; (2) count the number of times each word in the words array appears in the user's text; (3) store these counts in wc; and (4) then create a page on-the-fly that prints a twelve row table with each row containing two columns: (a) Ten rows with each row containing a column with a word from the words array and a column the number of occurrences of the word in the user's text; (b) a row with with the most frequently occurring word in the first column and a column with the number of times it occurs (if there are ties, print only the last one, if there are none print "None"; and (c) the last row containing in the first column the word "TOTAL" and in the second column contains the total number of words found.

Enter Your Movie Review

2.(40 points) A web page contains: (1) a form named lottery_form; (2) six select boxes named sel1; sel2; sel3; sel4; sel5; and sel6; (3) four checkboxes named c1; c2; c3; and c4 (all initially unchecked) and (4) an button named but2 which is labelled "CHECK MY PICKS". Each select box contains 51 options (the first option in each selectbox is "Pick A Number Below" followed by 50 options containing the digits 1 through 50). The first option is always "selected" in each select box at load time.

The user is directed to make six selections from the six select boxes and then press "CHECK MY PICKS". When the user presses the button, a sub named advise is executed. This sub should perform four tests:

  1. All picks must be a digits (i.e., some selection other than first must be made in each select box)

    If this condition is met, the program should place a check in c1

  2. All picks must be different (i.e., no two selections can be the same)

    If this condition is met, the program should place a check in c2

  3. All picks must differ by more than one digit (i.e., no two adjacent digits can be chosen -- for example the user cannot choose 21 and then choose 20 or 22 in any other select box)

    If this condition is met, the program should place a check in c3

  4. If the user choices pass all three tests above, place a check in c4.


All picks are digits
All picks are different
All picks differ by more than one digit
All picks are ok