a) Four constructors: one for the degrees, one for the scale, one for both the degrees and scale, and a no-argument constructor. For each of these constructors, assume zero degrees if no value is specified and Celsius if no scale is given.
b) Three accessor methods: one to return the temperature in degrees Celsius, one to return the temperature in degrees Fahrenheit, one to return the temperature in degrees Kelvin.
For conversion between scales you can use the following formulas:
Celsius = 5/9 x (Fahrenheit - 32)
Kelvin = Celsius + 273.15
c) Three set methods: one to set the temperature, one to set the scale and one to set both.
d) Three comparison methods: one to test whether two temperatures are equal, one to test whether one temperature is greater than the other and one to test whether one temperature is less than the other.
e) a toString method: to display the temperature and scale. The output should look like 32° C (You can copy the degree sign from here to put in your code)
Write a test program to demonstrate your class. Be sure to use all of your methods in the test program.
This question was asked on Mar 15, 2010.
Recently Asked Questions
- Final: Make a Marketing Plan for a failed business that you were given the opportunity to bring back Provide the following Cover page table of contents
- How do you calculate unit variable cost from only knowing the selling price and the contribution margin ratio?
- A company's CFO wants to maintain a target debt-to-equity ratio of 1/4. If the WACC is 18.6%, and the pretax cost of debt is 9.4%, what is the cost of common