COP 2800 (Java Programming) Project #2
Temperature Conversion Chart


Due: by the start of class on the date shown on the syllabus


Using as a model, create a Java stand-alone GUI program that displays a Fahrenheit to Celsius temperature conversion table in an AWT Frame or a swing JFrame.  The table should run from 0 degrees Fahrenheit to 250 degrees Fahrenheit, in steps of 10 degrees.  Round the Celsius temperature values to the nearest integer.

Display any temperatures below the freezing point of water (32o Fahrenheit) in blue and any temperatures above the boiling point of water (212o Fahrenheit) in red (the rest in black).

The formula to use is:

Degrees Celsius = ( 5 ÷ 9 ) × ( Degrees Fahrenheit - 32 Degrees )

Your applet should have appropriate column labels, and a chart title.  See the model solution on the website.

See TempConv.jar model solution for a sample chart; just download and double-click to run. 

Other Requirements:

You must turn in a stand-alone AWT or swing program, not an Applet or JApplet nor a JavaFx program.  You must meet all the requirements from the description above.  If you include any creative extras, be sure your program still performs the basic chart as described above.  Creative extras are extras, and you are not free to modify the project requirements.

It is not acceptable to pre-compute each Celsius value, and just have many “g.drawString()” statements.  You need to use Java to calculate each value using the correct formula, and use various control structures.

A non-working project can score quite well (so don't be afraid to turn one in).  Also a fully working project may not score 100%.

You must work alone on your project, however you can ask your instructor for help anytime.  Please see the syllabus for additional information about projects.

Your chart need not look like the sample (which is ugly on purpose, so you can more easily do better).  Try to be creative!  You will not be graded on the artistic merits of your chart.


If you don't know how to start crafting a program from a written problem description, How To Develop Your First Java Program may help.

Comments can be difficult for some students.  The trick is to know your audience: another Java programmer.  You therefore don't want to include comments like the following:

int i;    // declaring i as an int
i += 10;  // adding 10 to i

A Java programmer already understands such code.  Instead you should have comments that explain why you are declaring i, and why are you adding 10 to i.  You also should have some comments at the top of every file with a brief description of the file and your name.

A great way to come up with your comments is to first enter your design as a skeleton class with nothing but comments in the method(s).  Later, you fill in the code below each comment.

Use to start with; just change the class and file names, and update the comments.  Use the statements in the paint() method of for examples of drawing lines, rectangles, and text, and setting colors and fonts.  Note, you don't need to change any method except for paint in this project.

Use g.setColor() to change the color of the subsequent text.  (See the paint() method of for examples of this.)  To draw numbers or text, you can use:

g.drawString( "   " + fvalue + "   " + cvalue, col, row );

Where col and row are integer values of pixels.  Each line of text should be on a different row or else all your text will be drawn one row on top of each other, resulting in an ugly scribble.  A line a text is about 10-12 pixels tall, so rows should be about 12-15 pixels apart.

It is not required to align the columns of numbers on the right.  Doing so can be difficult if you don't know the secret!  If you really want to try this, one way is to use a Monospaced font, and String.format() to pad each number to the same width.  (This isn't simple; it is just simpler than the way that works for any font.)

Some possibly interesting Unicode characters are "\u2103" (for " °C "), "\u2109" (for " °F "), "\u00A9" (for " © "), and "\u00B0" (for " ° ").  These Unicode symbols may or may not work on your system, depending on which fonts are installed.  (No font includes all Unicode symbols.)

To be turned in:

Email to me your Java source file, by copy-and-paste (no attachments please!).

Submit projects to .  Please use a subject such as Java Temp Conversion Project so I can tell which emails are submitted projects.  Send project questions to .  Please use a subject such as Java Temp Convert Project Questions so I can tell which emails are questions about the project.

Please review Submitting Assignments and Project Grading Criteria from your class syllabus for further details.