CSIS 113B Midterm


In html colors are set using 3 separate hex values. These values called a triplet and are in the range of 0 - FF (0 - 255 decimal) and allow you set a degree of red green or blue. If you want to set the color to all red, you would have a triplet that looks something like this: FF,0,0 This says that you have the red at 100% and green and blue at 0. If you are an artitist or know something about color then you know that you could really create some custom colors.

The problem you are to tackle on your midterm is that html color charts show colors in hex values but languages like JAVA and VRML  use whole number values or a value that represents a percentage of how much color. In Java, If you want all red then your triple would look something like this 1.0, 0.0, 0.0. This says put red at 100% and green and blue at 0%. Java also will allow you to use an integer whole number. So to create all red you would have something like this 255,0,0. Your mission is to construct a converter that will allow the user to input the values in the HTML Hex format, you will then print out what the equivalent values are in both percentages and whole number. Look at the program below and try to duplicate it.

Input A Value In Hex


Specifics:

  1. Create a class called colorConverter. Store it in a file called colorConverter.java
  2. You need to create two methods to do the calculations for the color. For this assignment you do not have to pass or return values to the methods

To get a hex value and to convert it to number you can use the following:

 int num = Integer.valueOf("FF", 16);

 Note: The above is just an example, you will use the value collected from a JTextField and put it where the FF is. PLEASE Do not copy and paste this and expect it to work.

Finally, if you do not understand hex numbers you can read about them here:

http://programming.msjc.edu/asm/Unit1/DataRepresentation.aspx

We can also discuss this on the discussion board.

Grading criteria

Please Note To receive any credit for this project you must submit your source code to the appropriate student submission link and have your link working in your home page.