Solution to questions for Test 1


Question 1 Solution

[10 pts] graded by Tanmay

(10 pts) Write the complete HTML code that will

a) display in the browser's title bar the title "HTML is Fun!"

b) display in the same browser window a level 1 heading that says "Did Florida Really Vote For" and a centered level 3 heading that says "George Bush."

Solution:

<html>
   <head>
      <title> HTML is fun ! </title>
   </head>
   <body>
      <h3>Did Florida really vote for </h3>
      <center>
         <h3> George Bush</h3>
      </center>

   </body>
</html>


Question 2 Solution

[20 pts] graded by Dan

Part 1 (10 pts)

<HTML >
<BODY >

<UL >
<LI > dishes
<LI > pots
<LI > pans
</UL >

<OL >
<LI > dishes
<LI > pots
<LI > pans
</OL >

</BODY >
</HTML >
  • dishes
  • pots
  • pans
  1. dishes
  2. pots
  3. pans

Part 2 (10 pts)

  1. Types of Dogs
    • Cocker Spaniel
    • Scottie
    • Collie
  2. Types of Fish
    • Walleyed Pike
    • Northern Pike
    • Eelpout
<OL>
<LI> Types of Dogs <UL>
                                 <LI> Cocker Spaniel
                                 <LI> Scottie
                                 <LI> Collie
</UL>
<LI> Types of Fish <UL>
                                 <LI> Walleyed Pike
                                 <LI> Northern Pike
                                 <LI> Eelpout
</UL>
</OL>

Question 3 Solution

[10 pts] graded by Tanmay

3. (10 pts) Write the HTML code snippet that will display the image in the file "smiley.gif" so that it is left aligned in the browser window with the text "Here is My Smiley Face" to the right of the image. Also, please draw a picture of how you expect the browser to render your HTML code.

Solution:

The picture should be left aligned so that the text appears on the right of it.

Here is my smiley face!

 

<img scr="smiley.gif" align="left">Here is my smiley face!

Question 4 Solution

[10 pts] graded by Dan

red white blue
R G B
<TABLE BORDER WIDTH=100%>
<TR>
<TD>red </TD>
<TD>white </TD>
<TD>blue </TD>
</TR>
<TR>
<TD>R </TD>
<TD>G </TD>
<TD>B </TD>
</TR>
</TABLE>


Question 5 Solution

[15 pts] graded by Tanmay

5. Write the HTML code snippet for displaying a form with two checkboxes labeled "Check box 1" and "Check box 2" and two radio buttons labeled "Radio button 1" and "Radio button 2."

Solution:

Check Box 1
Check Box 2
Radio Button 1
Radio Button 2

<FORM NAME="form1">
<INPUT TYPE="checkbox" NAME="cb1" > Check Box 1
<INPUT TYPE="checkbox" NAME="cb2" > Check Box 2
<INPUT TYPE="radio" NAME="myRadio" VALUE="RB_1"> Radio Button 1
<INPUT TYPE="radio" NAME="myRadio" VALUE="RB_2"> Radio Button 2
</FORM>

Question 6 Solution

[10 pts] graded by Dan

First create a new temporary box and call it temp.

temp = box A;

box A = box B;

box B = temp;


Question 7 Solution

[10 pts] graded by Tanmay

Write an algorithm that will calculate the average value in a collection of 8 boxes labeled "box1," "box2," ... "box8."

Solution:

The boxes are labelled "box1", "box2", ..... ,"box8".
Algorithm to calcuate the average:
In words: Add up all the numbers in boxes 1 through 8. Divide the total by 8. The value thus obtained is the average.
Psuedocode:
1. Initialize a number sum to 0.
2. Loop through boxes 1 to 8, each time adding the value of the current box to sum.
i.e. sum = sum + value(current box).
3. Average = sum / 8.
(Either one of the methods to explain the algorithm is acceptable.)


Question 8 Solution

[15 pts] graded by Dan

There were several different possible answers. Here are some of them:

Find the largest number and remove it from the list, then find the largest number in the new list.

Find the largest number in the list, the find the largest number in the list and ignore the previous largest number.

Sort a list of n numbers in ascending order and return the n-1 number in the list.

Sort the list in descending order and return the 2nd number in the list.