Java, Java, Java 3E
Chapter 2: Objects: Using, Creating, and Defining
Ch 2 Lab: The Temperature Class
Brief Description
This lab asks students to use the
Riddle class, discussed in Chapters 1, as a model in
building the Temperature class that is capable of reporting
its temperature in either Fahrenheit or
Celsius. They are asked to draw a UML
diagram of the Temperature class, to translated that into
a written specification, and then to implement the class. The lab describes
creating a command line interface to the class.
The objectives of this lab are:
- To give practice designing a simple Java class to convert temperatures
from degrees Fahrenheit to degrees Celsius.
- To convert the design into a working Java program
- To compile, run and test the Java program
Your program should produce something like the following output in
the Java console:
The Fahrenheit temperature of thermometer1 is 20.0 degrees.
The Celsius temperature of thermometer1 is -6.67 degrees.
The Fahrenheit temperature of thermometer2 is 98.6 degrees.
The Celsius temperatureof thermometer2 is 37.0 degrees.