A Java Course Outline
Using the Java By Dissection book
by Ira Pohl and Charlie McDowell


Homework 2 - Table of Fahrenheit and Centigrade

We will write a program to print a table of temperatures. The program should print out this table at intervals of five degree's centigrade from 0 to 100. This is the range in which water is a liquid.

The formula for centrigrade to Fahrenheit is F = 9/5 C + 32.

The program should use a simple loop , either a for or while loop to print the table. The table should be easy to read. One point to keep in mind is that the program can be made more efficient by noting that the whole formula need not be recalculated at each step.

Extra Credit

For an extra challenge, after printing out the table, ask the user for for a range of temperatures and ask whether they want farenheit or centigrade, and then print out that range. Or you could do a conversion to Kelvin, just for fun.


To save yourself some time, before you sit down to start coding, design what you are going to write first. Whether you write a flow diagram or pseudo-code, make sure you define to yourself what the program will print. Then set to work designing how it will print.

Be careful to read the directions and understand them before plunging headlong into this assignment.

Remember, what you are trying to get out of this homework is more practice with the development environment, an understanding of useful user interface, and some practice with loops. Understand these things this week, and next week's program will be all that much easier.

If you are having trouble with your for loops, copy or print out the ForTester.java source code. Then very carefully write out what each section will print up. This may seem tedious, then compile and run the program... did the program's output match what you wrote down? If not, can you explain why it didn't?

Write a simple program that counts from 1 to 10. When you have that working, count from 2 to 20 by 2s. Count backwards from 10 to 0. If you've already worked on the ForTester.java exercise above, this will make much more sense.

Feel free to report any site problems to the Webmaster, Debra Dolsberry.