] > Assignment 2: A Table of Unicode Characters (Due: Th, Oct 16)

Assignment 2: A Table of Unicode Characters (Due: Th, Oct 16)

Write a program ‘Uni.java’ that prepares a HTML file ‘uni.html’ showing 80 consecutive unicode characters. The characters should be displayed within a table of 10 rows by 8 columns. The program should get for an input a file ‘in.txt’ with the decimal number of the first unicode character in the sequence.

Notes.

The following example illustrates how a HTML page can display a table.

@ A
B C
<html>  
<head>  
   <style type=’text/css’>  
      td{ padding : 5pt; }  
      table[rules], td  
        { border : solid black 0.4pt; }  
   </style>  
</head>  
<body>  
   <table rules="groups">  
     <tr>  
       <td>&#64;</td>  
       <td>&#65;</td>  
     </tr>  
     <tr>  
       <td>&#66;</td>  
       <td>&#67;</td>  
     </tr>  
   </table>  
</body>  
</html>

Suggestion. Build your program incrementally in the following manner.

  1. Have the program print the following parts using just System.out.println instructions.

    Part 1
    <html>  
    <head>  
       <style type=’text/css’>  
          td{ padding : 5pt; }  
          table[rules], td  
            { border : solid black 0.4pt; }  
       </style>  
    </head>  
    <body>  
       <table rules="groups">
    Part 2
    <tr>  
      <td>&#64;</td>  
      <td>&#65;</td>  
    </tr>  
    <tr>  
      <td>&#66;</td>  
      <td>&#67;</td>  
    </tr>
    Part 3
       </table>  
    </body>  
    </html>

    That is, the program should be a larger variant of the following program.

  2. Check with a browser that the obtained file provides the following outcome.

    @ A
    B C
  3. Modify the Java code for the second part so that it will refer to an integer variable instead of the integer constants 64, 65, 66, and 67. The integer variable should be initialized to 64, and its value should be incremented after each time it is being used.
  4. Modify the Java code for the second part so that it will refer exactly once to each of the strings <tr>, </tr>, <td>, and </td>. That can be done with the help of loops.
  5. Modify the Java code for the second part so that it will produce a table of 10 rows and 8 columns. That can be done through the control variables of the loops.
  6. Instead of having the constant 64 hard coded within the program, have the Java program read an integer from the input file.

    Note that a loop can be used to process the different digits. For instance, a conversion of an input string 64 into an integer value can be as follows.

    (’6’ - ’0’) * 10 + (’4’ - ’0’)

Posting web pages. Web pages can be posted in the following manner on the CSE site.

  1. Create at the root directory a subdirectory named WWW.

    mkdir ~/WWW

    Note that WWW should be in uppercase letters.

  2. Make the WWW directory globally accessible.

    chmod 711 ~/WWW

  3. Copy the HTML file to the WWW directory.

    cp uni.html ~/WWW/.

  4. Make the HTML file globally readable.

    chmod 644 ~/WWW/uni.html

  5. The URL for the web page will be

    http://www.cse.ohio-state.edu/~your-user-name/uni.html