| How to Submit Solutions for this Homework/Computer Lab | |
|---|---|
| Due Date: | Friday 11-17-06 |
| E-mail To: | ![]() |
| Subject Line: | HWCL 10 |
| 1'st Line: | Your name and student number |
This computer lab is written for Windows 9x/2000/NT/XT based PCs, with a Mozilla/Firefox Browser or an Internet Explorer. Those portions of the lab that are not platform-specific can also be run on a Mac.
The goals of this computer lab are:
You will need some or all of the following programs for this computer lab. Download them and, if necessary, unpack and install them on the computer that you use to run this lab.
7-Zip is a file archiver with high compression ratio. It supports
the 7z, ZIP, GZIP, BZIP2 and TAR formats for both packing and unpacking.
Unpacking only is supported for the RAR, CAB, ISO, ARJ, LZH, CHM, Z,
CPIO, RPM, DEB, and NSIS formats. The home page of 7-Zip is at
http://www.7-zip.org.
EditPlus V2.21 is an Internet-ready, 32-bit text editor for Windows.
It offers many powerful features for Web page authors and programmers and
has powerful syntax highlighting for HTML, JavaScript, Perl, Java, C/C++
and any other programming language, based on the default syntax files or
user-defined syntax files, for both the screen display and the printing.
A
spell checker (US version) is also available.
The home page for EditPlus is at
http://www.editplus.com.
Note: If you cannot install EditPlus because you have no administrator
privileges, then you should use the files in
epp221run.7z
after unpacking (with the 7-Zip program) to a directory of your choice.
Image Analyzer 1.26 is an image editing, enhancement and analysis
program. It can read/write and convert between BMP, ICO, CUR, WMF, EMF,
JPEG, PNG, PCX, JPEG2000, GIF, and TIF image formats. The home page of
Image Analyzer is at
http://meesoft.logicnet.dk.
LViewPro 1.D/32 is a very compact image viewer, editor, and file format
converter. The home page of LViewPro is at
http://www.lview.com.
Tables are used frequently to display and organize data and information. In connection with the Internet, electronic publishing, and telecommunications tables are used for:
In general a m×n table is a rectangular structure with m rows and n columns, as shown below for m = 3 and n = 5.
| <----- n = 5 columns -----> | ||||||||||||||||
| ^ | m = 3 rows | v |
|
Some cells in a table can be merged together to produce larger cells, e.g., as shown below:
| <----- n = 5 columns -----> | ||||||||||||||
| ^ | m = 3 rows | v |
| |||||||||||||
This is one of the features that makes tables powerful tools for page layout control.
Tables can be nested, i.e., one or more tables can be inside another table. The example below shows a 3×5 table inside a 2×3 table.
| (a,a) |
(a,b) | (a,c) | |||||||||||||||
| (b,a) | (b,b) |
|




Example: Tables for addition and multiplication modulo m=5. Note that in this case m is a prime number.
|
|
Example: Tables for addition and multiplication modulo m=6. Note that in this case m is a composite number.
|
|
When m is a composite number, then the product
of two nonzero numbers can become 0, e.g.,
3×4=12
0
(mod 6). This cannot happen if m is a
prime number.


Numbers appear in different forms and places on the WWW and in HTML documents. IP addresses are 32-bit numbers (under IP V4), that are usually represented in dotted decimal form, e.g., as in 128.138.189.30. Here each of the 4 decimal numbers is in the range 0...255 and represents 8 out of the 32 bits. ASCII encoded characters, numbers, etc., are also using either 7 or 8 bits and can therefore be treated as decimal numbers in the range 0...127 (original ASCII code) or 0...255 (original ASCII plus extended §þêçïå£ character sets). Finally, colors are usually specified as RGB (red, green, blue) 3-tuples, e.g., "#FF68B0" ("#FF68B0") for hotpink, where the first two digits specify the amount of red in hexadecimal (hex) format, the second two digits specify the amount of green in hex, and the last two digits specify the amount of blue, also in hex. In this case each two-digit hexadecimal number again stands for 8 bits and can take on values in the range 00...FF. Some image programs use decimal numbers in the range 0...255 instead of the hexadecimal numbers that need to be used in HTML tag attributes. Thus, there is a need to be able to convert between binary, decimal, and hexadecimal numbers.
A decimal number is a number that consists of the decimal digits 0,1,2,3,4,5,6,7,8,9. The interpretation of a number like 2537 is:
| Decimal | Interpretation |
|---|---|
| 2537 | = 2×103 + 5×102 + 3×101 + 7×100 |
A binary number consists of a string of bits and the interpretation of a number like 10010101 is done exactly in the same way as for decimal numbers, except that the basis is now taken to be 2 rather than 10:
| Binary | Interpretation | Decimal |
|---|---|---|
| 10010101 | = 1×27 + 0×26 + 0×25 + 1×24 + 0×23 + 1×22 + 0×21 + 1×20 | = 149 |
To simplify the conversion from 8-bit binary numbers to decimal numbers and vice versa, you can use the following two tables. The binary number for a given decimal entry, e.g., 103, is found by concatenating the binary number above (0110..) with the binary number to the left (..0111) to form 01100111.
| 0000.. | 0001.. | 0010.. | 0011.. | 0100.. | 0101.. | 0110.. | 0111.. | |
|---|---|---|---|---|---|---|---|---|
| ..0000 | 0 | 16 | 32 | 48 | 64 | 80 | 96 | 112 |
| ..0001 | 1 | 17 | 33 | 49 | 65 | 81 | 97 | 113 |
| ..0010 | 2 | 18 | 34 | 50 | 66 | 82 | 98 | 114 |
| ..0011 | 3 | 19 | 35 | 51 | 67 | 83 | 99 | 115 |
| ..0100 | 4 | 20 | 36 | 52 | 68 | 84 | 100 | 116 |
| ..0101 | 5 | 21 | 37 | 53 | 69 | 85 | 101 | 117 |
| ..0110 | 6 | 22 | 38 | 54 | 70 | 86 | 102 | 118 |
| ..0111 | 7 | 23 | 39 | 55 | 71 | 87 | 103 | 119 |
| ..1000 | 8 | 24 | 40 | 56 | 72 | 88 | 104 | 120 |
| ..1001 | 9 | 25 | 41 | 57 | 73 | 89 | 105 | 121 |
| ..1010 | 10 | 26 | 42 | 58 | 74 | 90 | 106 | 122 |
| ..1011 | 11 | 27 | 43 | 59 | 75 | 91 | 107 | 123 |
| ..1100 | 12 | 28 | 44 | 60 | 76 | 92 | 108 | 124 |
| ..1101 | 13 | 29 | 45 | 61 | 77 | 93 | 109 | 125 |
| ..1110 | 14 | 30 | 46 | 62 | 78 | 94 | 110 | 126 |
| ..1111 | 15 | 31 | 47 | 63 | 79 | 95 | 111 | 127 |
| 1000.. | 1001.. | 1010.. | 1011.. | 1100.. | 1101.. | 1110.. | 1111.. | |
|---|---|---|---|---|---|---|---|---|
| ..0000 | 128 | 144 | 160 | 176 | 192 | 208 | 224 | 240 |
| ..0001 | 129 | 145 | 161 | 177 | 193 | 209 | 225 | 241 |
| ..0010 | 130 | 146 | 162 | 178 | 194 | 210 | 226 | 242 |
| ..0011 | 131 | 147 | 163 | 179 | 195 | 211 | 227 | 243 |
| ..0100 | 132 | 148 | 164 | 180 | 196 | 212 | 228 | 244 |
| ..0101 | 133 | 149 | 165 | 181 | 197 | 213 | 229 | 245 |
| ..0110 | 134 | 150 | 166 | 182 | 198 | 214 | 230 | 246 |
| ..0111 | 135 | 151 | 167 | 183 | 199 | 215 | 231 | 247 |
| ..1000 | 136 | 152 | 168 | 184 | 200 | 216 | 232 | 248 |
| ..1001 | 137 | 153 | 169 | 185 | 201 | 217 | 233 | 249 |
| ..1010 | 138 | 154 | 170 | 186 | 202 | 218 | 234 | 250 |
| ..1011 | 139 | 155 | 171 | 187 | 203 | 219 | 235 | 251 |
| ..1100 | 140 | 156 | 172 | 188 | 204 | 220 | 236 | 252 |
| ..1101 | 141 | 157 | 173 | 189 | 205 | 221 | 237 | 253 |
| ..1110 | 142 | 158 | 174 | 190 | 206 | 222 | 238 | 254 |
| ..1111 | 143 | 159 | 175 | 191 | 207 | 223 | 239 | 255 |
Hexadecimal (or simply hex) numbers are made up from the digits 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F and they use the number 16 as basis. The digits A,B,C,D,E,F represent the numbers 10,11,12,13,14,15, respectively. The interpretation of a number like A9FD is:
| Hex | Interpretation | Decimal |
|---|---|---|
| A9FD | = 10×163 + 9×162 + 15×161 + 13×160 | = 43,517 |
Because 24 = 16, conversion between binary and hexadecimal numbers is very easy. In fact, the main use of the hexadecimal number system is to be able to write binary numbers in a more compact form. Any combination of 4 bits can be expressed by a single hexadecimal digit as shown in the following table:
| Hex | Binary | Decimal |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 3 |
| 4 | 0100 | 4 |
| 5 | 0101 | 5 |
| 6 | 0110 | 6 |
| 7 | 0111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| A | 1010 | 10 |
| B | 1011 | 11 |
| C | 1100 | 12 |
| D | 1101 | 13 |
| E | 1110 | 14 |
| F | 1111 | 15 |
Example: To convert the decimal number 155 to hexadecimal, we can use the decimal to binary conversion tables above to find that 155 is 10011011 in binary. The first 4 bits then convert to 9 and the second 4 bits convert to B. Thus, decimal 155 converts to hexadecimal 9B.
TVs and computer screens use the so called additive color system. Three primary colors, red (R), green (G), and blue (B) are used in varying proportions to generate (almost all) visible colors. This is shown graphically in the following picture.

In HTML colors can be specified by strings of the form "#RRGGBB", where RR, GG, BB are hexadecimal numbers in the range 00..FF which specify the amount of red, green, and blue contained in a particular color. The value 00 means that this color is not present and the value FF (equal to 255 in decimal) is the maximum intensity for each color. Black is "#000000" (or 0,0,0 in decimal) and white is "#FFFFFF" (or 255,255,255 in decimal). Other colors are shown in the table below.
| Color | Color Name | Attribute Value |
|---|---|---|
| * | Black | "#000000" |
| * | Gray | "#808080" |
| * | Silver | "#C0C0C0" |
| * | White | "#FFFFFF" |
| * | Maroon | "#800000" |
| * | Olive | "#808000" |
| * | Dark Green | "#008000" |
| * | Teal | "#008080" |
| * | Navy | "#000080" |
| * | Purple | "#800080" |
| * | Red | "#FF0000" |
| * | Yellow | "#FFFF00" |
| * | Lime (or Green) | "#00FF00" |
| * | Aqua (or Cyan) | "#00FFFF" |
| * | Blue | "#0000FF" |
| * | Fuchsia (or Magenta) | "#FF00FF" |
If you have a decimal color specification of the form (R,G,B), where R, G, and B can each take on values in the range 0..255, then you can use LViewPro as follows to display the corresponding color. First load any JPEG image, e.g., hsv2.jpg into LViewPro. Then click on "Retouch" and select "Background color". Use the sliders in the window that pops up to generate the color with the given values for R, G, and B. The example below shows this for (R,G,B)=(255,128,128).
Suppose a color is represented in decimal in the form of a 3-tuple (R,G,B), where R, G, and B can each take on values in the range 0..255 (00..FF in hexadecimal). Then one can also define a second related color by (255-R,255-G,255-B). This color is called the complementary color of the one represented by (R,G,B). The following table shows some elementary pairs of colors and their complements. Others can easily be found by using the technique for displaying specified colors in LViewPro as outlined above. For a more extensive list of HTML colors and names see colors.html.
| Color | Complementary Color | ||
|---|---|---|---|
| * | (0,0,0) = "#000000" | (255,255,255) = "#FFFFFF" | * |
| * | (255,0,0) = "#FF0000" | (0,255,255) = "#00FFFF" | * |
| * | (0,255,0) = "#00FF00" | (255,0,255) = "#FF00FF" | * |
| * | (0,0,255) = "#0000FF" | (255,255,0) = "#FFFF00" | * |
Text, like anything else, needs to be stored and transmitted in binary form for computers. There are 26 lower case and 26 upper case letters in the alphabet. Add to this the 10 digits for numbers and (at least) 10 punctuation marks (e.g., , . ! ? : ; ( ) - /). This adds up to (at least) 72 distinct characters that need to be uniquely encoded in binary. Since log(72)/log(2) = 6.1699, we need (at least) b=7 bits to encode each character. The most widely used code for the English alphabet is the ASCII (American Standard Code for Information Interchange) code which was developed in 1962. This code is shown in the following table.
| 000.. | 001.. | 010.. | 011.. | 100.. | 101.. | 110.. | 111.. | |
|---|---|---|---|---|---|---|---|---|
| ..0000 | NUL | DLE | SP | 0 | @ | P | ` | p |
| ..0001 | SOH | DC1 | ! | 1 | A | Q | a | q |
| ..0010 | STX | DC2 | " | 2 | B | R | b | r |
| ..0011 | ETX | DC3 | # | 3 | C | S | c | s |
| ..0100 | EOT | DC4 | $ | 4 | D | T | d | t |
| ..0101 | ENQ | NAK | % | 5 | E | U | e | u |
| ..0110 | ACK | SYN | & | 6 | F | V | f | v |
| ..0111 | BEL | ETB | ' | 7 | G | W | g | w |
| ..1000 | BS | CAN | ( | 8 | H | X | h | x |
| ..1001 | HT | EM | ) | 9 | I | Y | i | y |
| ..1010 | LF | SUB | * | : | J | Z | j | z |
| ..1011 | VT | ESC | + | ; | K | [ | k | { |
| ..1100 | FF | FS | , | < | L | \ | l | | |
| ..1101 | CR | GS | - | = | M | ] | m | } |
| ..1110 | SO | RS | . | > | N | ^ | n | ~ |
| ..1111 | SI | US | / | ? | O | _ | o | DEL |
To find the binary code of a character, say C, you locate the desired character in the table and then you concatenate the binary string directly above (100.. for C) with the binary string to the left (..0011 for C). For C the resulting binary code is thus 1000011.
The ASCII code can be extended by adding an 8-th bit (to make each code a byte). The original ASCII characters are prefixed by 0 (thus C in the above example becomes 01000011). Special characters (which are an extension of the original ASCII code) are prefixed by 1 (e.g., 10100011 is the British pound sign £). Most of the special characters have no corresponding key on regular keyboards. To enter them in a HTML document, the special combination &#xx; is used where xx is a decimal number in the range 0..255. Examples are shown in the following table.
| Character Reference | Resulting Character |
|---|---|
| " | " |
| & | & |
| < | < |
| > | > |
| A | A |
| B | B |
| C | C |
| ™ | |
| § | § |
| © | © |
| ® | ® |
| µ | µ |
| ü | ü |
Some special characters, such as the copyright symbol ©, also have special names in HTML by which they can be inserted into a document, e.g., © for ©, where the "escape" character & itself is entered as &. The following table shows some more examples.
| Character Reference | Resulting Character |
|---|---|
| | non-blank space |
| < | < |
| > | > |
| & | & |
| © | © |
| " | " |
The table below shows all extended ASCII characters, i.e., all characters whose 8-th bit is set to 1 (decimal code in range 128..255). When using these characters, be aware of the fact that different browsers and/or different operating systems may interpret the codes differently.
| 1000.. | 1001.. | 1010.. | 1011.. | 1100.. | 1101.. | 1110.. | 1111.. | |
|---|---|---|---|---|---|---|---|---|
| ..0000 | | | ° | À | Ð | à | ð | |
| ..0001 | | | ¡ | ± | Á | Ñ | á | ñ |
| ..0010 | | | ¢ | ² | Â | Ò | â | ò |
| ..0011 | | | £ | ³ | Ã | Ó | ã | ó |
| ..0100 | | | ¤ | ´ | Ä | Ô | ä | ô |
| ..0101 | | ¥ | µ | Å | Õ | å | õ | |
| ..0110 | | | ¦ | ¶ | Æ | Ö | æ | ö |
| ..0111 | | | § | · | Ç | × | ç | ÷ |
| ..1000 | | | ¨ | ¸ | È | Ø | è | ø |
| ..1001 | | | © | ¹ | É | Ù | é | ù |
| ..1010 | | | ª | º | Ê | Ú | ê | ú |
| ..1011 | | | « | » | Ë | Û | ë | û |
| ..1100 | | | ¬ | ¼ | Ì | Ü | ì | ü |
| ..1101 | | | | ½ | Í | Ý | í | ý |
| ..1110 | | | ® | ¾ | Î | Þ | î | þ |
| ..1111 | | | ¯ | ¿ | Ï | ß | ï | ÿ |
Each cell in a table can contain either a single item, such as text or an image, or a whole document with several paragraphs of text, images, sounds, etc. Web page designers quickly realized the potential of tables as design elements for the visual appearance of HTML documents. A very simple example is a two-column text format as shown in Origins of Interesting Companies, similar to newspapers or articles in magazines. It was mentioned earlier that HTML was originally intended to be a logical document description language, which leaves all aspects of how a document is rendered to the browser that a user employs for viewing documents. It is therefore not surprising that the use of tables as visual design aids is somewhat controversial and not encouraged by the World-Wide Web Consortium, which prepares and issues recommendations for the standardization of HTML. There is a newer mechanism, called cascading style sheets (CSS) (similar to the use of templates in a word processor) that can be used in HTML 4, but because of added complexity and compatibility issues with older browsers, many Web sites do not (yet) use this mechanism for page layout.
If you want your HTML documents to be viewable by as large an audience as possible (working on different platforms and often not with the newest version of a particular browser), then you have to be careful in using only a "safe" subset of all possible table-related tags. It is one of Microsoft's favorite strategies to invent new and/or slightly different tags which only their browser understands, and then to sell a page design program like Frontpage, that uses those tags wherever possible, so that other competing browsers cannot display a document properly. The hope is then that the users will switch to Internet Explorer, and all competitors are wiped out. The following table, called tabletest1.html, should display properly in both Netscape and Internet Explorer, and it gives you a first idea of the design options that you have when using tables.

To start (and end) a table, you need a table container, inside which you can then define rows and columns, or even other tables. The most important rules for the <table> tag are shown in the following table.
| table Element: Tables and Tabular Structures | |
|---|---|
| Usage: | <table> ... </table> |
| Can contain: | caption, tr |
| Can be inside: | blockquote, body, center, dd, div, form, li, td, th |
| Attributes: | bgcolor, border, cellpadding, cellspacing |
Tables are organized by rows using the tags <tr> and </tr>. Each entry within a row can either be a header entry marked by <th> and </th> tags, or a data entry marked by <td> and </td> tags. A table caption can be included as well. Here's an example of a simple table with a border:
| HTML Tags | Resulting Display | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
<table border="1"> <caption>Simple Table</caption> <tr> <th></th> <th>Col 1</th> <th>Col 2</th> </tr> <tr> <th>Row 1</th> <td>x(1,1)</td> <td>x(1,2)</td> </tr> <tr> <th>Row 2</th> <td>x(2,1)</td> <td>x(2,2)</td> </tr> <tr> <th>Row 3</th> <td>x(3,1)</td> <td>x(3,2)</td> </tr> </table> |
|
The background color of a table (or a single data or header entry) can be selected with the attribute bgcolor="color" where color is one of the colors from the HTML Color Table (not all browsers will necessarily understand all of these colors, but as explained above, it is also possible to specify colors directly in terms of numerical values for red, green and blue components). Here's an example of a table that uses a white background and no border:
| HTML Tags | Resulting Display | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
<table border="0" bgcolor="white" cellspacing="0" cellpadding="4"> <caption>Simple Table</caption> <tr> <th> </th> <th>Col 1</th> <th>Col 2</th> </tr> <tr> <th>Row 1</th> <td>x(1,1)</td> <td>x(1,2)</td> </tr> <tr> <th>Row 2</th> <td>x(2,1)</td> <td>x(2,2)</td> </tr> <tr> <th>Row 3</th> <td>x(3,1)</td> <td>x(3,2)</td> </tr> </table> |
|
The following screen shot of tabletest2.html shows the relationship between the cellspacing and cellpadding attributes in the <table> tag.

Here are some more tags and attributes that are useful to control various aspects of tables:
| tr Element: Table Row | |
|---|---|
| Usage: | <tr> ... </tr> |
| Can contain: | th, td |
| Can be inside: | table |
| Attributes: | align, bgcolor, valign |
| td and th Elements: Table Data and Table Headers | |
|---|---|
| Usage: |
<td> ... </td> <th> ... </th> |
| Can contain: | any characters, a, applet, br, img basefont, map, script, input, select, textarea, dir, dl, menu, ol, ul, p, hr, hn, sddress, blockquote, center, div, form, pre, table |
| Can be inside: | tr |
| Attributes: | align, bgcolor, colspan, height, rowspan, valign, width |
Note in particular the rowspan and the colspan attributes that allow you to make cells that span more than one row and/or columns. Look at the source code of tabletest1.html and tabletest2.html to see examples of how to use these tags.
One of your tasks in this computer lab is to find images, crop and/or rearrange them, upload them to the www directory of your WebFiles account, and incorporate them in an HTML document inside a table using the <img>, <table>, and related tags. You have to create a Picture Gallery similar to (but possibly less extensive than) the following example in My Picture Gallery.

When you put together a report or a story that is larger than what comfortably fits on a "page" (like a "home page"), then you need to come up with a design and a structure that will make the document easy to access, navigate, read, and maintain. Design elements are the colors that you use for text, background, and images, font face and size, heading styles, etc. Structural elements are the files and (sub)directories from which your document is made up, and the links between them.
A good document structure to start from is to have a main page, e.g., with an overview, from which you can branch out into more detailed subtopics, each on a separate page. As shown in the following figure, the files of a story could reside in their own subdirectory, with hypertext links (shown in blue) between the pages of the story, to the home page index.html in the parent directory, and more links to other sites on the WWW. A technique that is often used is to store images (especially those shared by many documents) in a common subdirectory. In the figure below this subdirectory is called images. The red lines show the references (in the form of <img src=...> tags) from the HTML pages to the images in the image folder.

Hypertext links (or anchors), shown in blue in the above figure, to any other electronic documents that are accessible through the Internet can be inserted (almost) anywhere in an HTML document. The general form of a hypertext link element is (a stands for "anchor"):
| HTML Element | Resulting Display |
|---|---|
| <a href="address">linktext</a> | linktext |
where address specifies the location of the linked document and linktext is the text that serves as the hypertext anchor ("clickable text", usually blue and underlined) for the linked document. The address can take on several different forms:
| HTML Element | Resulting Display |
|---|---|
| Go to <a href="#loc_name">ref_item</a> | Go to ref_item |
| HTML Element | Resulting Display |
|---|---|
| <a name="loc_name">ref_item</a> | ref_item |
To obtain credit for this homework/computer lab you need to answer the
questions stated below. Send your solution to
.
Rules for the Submission of Homework/Computerlab Solutions
Format: E-mail your solution as a plain text (ASCII) file. Do not use word processor files like Microsoft Word or "rich-text" HTML files.
Corrections: If you need to make corrections after you submitted your solution, resubmit all your answers (not only the ones that changed) since only your last submission of each homework/computer lab will be graded.
Teamwork: Teamwork is fine for the homework/computer labs, but the solutions must be turned in individually. In particular, copy and paste of entire solutions from other students is not acceptable.
Questions:
101x011,x101011,110xx01,1101001,1101x10,1100111into ASCII text using the above ASCII table. To make things a little more interesting, "erasures", marked with x have been introduced. An erasure is a mild form of a transmission error and each x in the binary string above could be either a 0 or a 1. Hint: When you choose the correct binary values for the x's (using trial and error), the string decodes into an English word.

©1996-2006, P. Mathys. Last revised: 11-09-06, PM.