Test your class definition by implementing a main() method that creates Temperature instances and displays their temperature values.
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.
/**
* Class Name: Temperature
*
* ... ( the rest of your specification )
*
*/
System. out. print(" The Fahrenheit temperature of
thermometer1 is ");
System. out. print( thermometer1. getFahrenheit());
System. out. println( " degrees.");
If time and energy permits, you may want to try this optional exercise, which makes use of Java's input class, BufferedReader.
The following statements must be incorporated into your program (IN THE CORRECT LOCATIONS):
import java.io.*; // The IO classes must be imported
...
public static void main(String argv[]) throws IOException // Main must be revised
...
// The following code should be added to the main() method
BufferedReader input = new BufferedReader( new InputStreamReader (System.in) );
String inputString;
double temp;
// The following code is used to input a double value and store it
// in the temp variable
System.out.println("Input a temperature in Fahrenheit degrees: " );
inputString = input.readLine();
temp = Double.valueOf(inputString.trim()).doubleValue();// The following statement could be used to create a Temperature
//object using the input value.Temperature thermometer1 = new Temperature(temp);
When your assignment is complete, add some comments to the beginning of the java source code explaining any problems you encountered in completing the assignment and describing any bugs in your solution. Undocumented bugs are worse than documented bugs. If you have undocumented bugs we will assume that you did an inadequate job of testing your code, and you will lose additional points.
To submit your homework, follow the link from the homework page to the homework submission form.
There will be a 10% penalty for assignments received after the due date. Assignments will not be accepted more than one week past the due date.