] > Assignment 3: Colored Arrays (Due: Th, Oct 23)

Assignment 3: Colored Arrays (Due: Th, Oct 23)

RGB is a coloring scheme based on mixing three colors: red (R), green (G), and blue (B). HTML allows to refer to such mixtures of colors through attributes of the following form, where i, j, and k represent integer numbers between 0 to 255.

style="color:rgb(i, j, k)"

Extend the Java program of Lab 2 so that the characters in the cells will be colored according to the following scheme.

Notes.

Example.

@ 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 style="color:rgb(0,127,127)">&#64;</td>  
       <td style="color:rgb(0,255,0)">&#65;</td>  
     </tr>  
     <tr>  
       <td style="color:rgb(0,0,255)">&#66;</td>  
       <td style="color:rgb(255,0,0)">&#67;</td>  
     </tr>  
   </table>  
</body>  
</html>

The characters A, B, and C receive random colors. The color of the character @ gets the average of the colors of the character at the end of row one and the character at the end of column one.

(0,255,0) + (0,0,255) 2 = (0,127,127)

Suggestion. Build your program incrementally in the following manner.

  1. Modify your program of Lab 2 to print all the characters using the red color.
  2. Define a 8-by-10 array. Initialize each cell to a random value in the range of 0–255.
  3. Modify the program to apply varying intensities of the red color for the characters. The intensities are to be obtained from the corresponding cells of the array.
  4. Modify the initialization of the array to calculate the average values for the non-end entries in the rows and columns.
  5. Employ similar arrays for the green and blue colors.