next up previous
Next: Make mistakes Up: Programming assignment Previous: Edit the program

Type in another program

1.
Return to the Hello.java window and modify your program so that it looks like the program on page 21. You should have an idea by now what things have to be exactly the same (like capitalization) and which things can vary without breaking the program (like comments and most spacing).
2.
Before you run the program you have to make a couple of changes. First, you can't call the class Temperature; you have to call it Hello, because that's the name of the file, and the name of the class has to be the same as the name of the file. This is a dumb rule that the otherwise sensible Java people came up with during a caffeine-induced frenzy. Nevertheless, it can be accomodated easily enough by making sure the name of the class is Hello.

IMPORTANT: If you ever forget this rule, and the class name is different from the file name, confusing things will happen. Avoid this situation!

3.
The second change you have to make is to get rid of the stuff that takes input from the keyboard. Instead, we are just going to set the temperature to 32. Delete line 8, and change line 9 to: temperature = 32;

4.
Run the program. Check that the output is correct (0 deg C), and quit the Roaster Runner.

5.
Modify the program to find the Celcius equivalent of -40F.


next up previous
Next: Make mistakes Up: Programming assignment Previous: Edit the program
Allen B. Downey
2/7/1998