hi i need help in this program that i am working on:
Write a Temperature class that has two data members one is temperature value ( double ) and the other is a type (char ) indicating 'F' or 'f' for the Fahrenheit scale or 'C' or 'c' for the Celsius scale.
Your class should have only the following methods:
Your class should have four constructors. One constructor should be the default constructor which will set the default temperature type to 'C'.
There should be three set methods for setting or resetting one or both of the data members. Names of these three methods should be set.
There should be one method named isCelsius which returns
true if the scale is Celsius and false otherwise.
There should be one method to take user input. Input temperature value may be a negative or non negative double number.
Do error checking on temperature type. The program should NOT exit if a character other than 'F' (or 'f') or 'C' (or 'c') is entered, but should force the user to enter a valid character.
There should be one output method to output both the data
members with appropriate message. The temperature value
should be displayed with only one digit after the decimal
point ( if required, you may use Math class or Format class. )
There should be one method named getFahrenheit which
returns the temperature in degrees Fahrenheit. Similarly there should be a method named getCelsius which returns the
temperature in degrees Celsius. ( Note that temperature might have been entered in any units 'F' or 'C', so you may need to do the conversion from one type to another. )
There should be three methods for comparing two temperature values. One for comparing equality, the second for less than and the third for greater than. These methods should return true or false depending on whether the two temperature values being compared are equal, one is less than the other, or one is greater than the other.
Write a demo class named demoTemperature which will
demonstrate use of the above methods. The demo class will ask the user to input two temperatures, and then will test the above methods using these two temperatures. The demo class should run EXACTLY as follows (pay special attention to order of input/output), with the only difference being the numbers that are inputted (they are just a sample):
---Testing input methods---
Inputting first temperature...
Input temperature: 212
Input scale (f/c): f
Inputting second temperature...
Input temperature: 120
Input scale (f/c): d
Invalid scale!
Input scale (f/c): c
---Testing output methods---
Outputting first temperature...
212.0 degrees Fahrenheit
Outputting second temperature...
120.0 degrees Celsius
---Testing conversion methods---
Converting first temperature...
212.0 degrees Fahrenheit is 100.0 degrees on the Celsius scale
Converting second temperature...
120.0 degrees Celsius is 248.0 degrees on the Fahrenheit scale
---Testing equality method---
212.0 degrees Fahrenheit
IS NOT EQUAL TO
120.0 degrees Celsius
---Testing greater than method---
212.0 degrees Fahrenheit
IS NOT GREATER THAN
120.0 degrees Celsius
---Testing less than method---
212.0 degrees Fahrenheit
IS LESS THAN
120.0 degrees Celsius
Please if any one can can help me out I would appreciate it a lot. Thank-You!!!
Write a Temperature class that has two data members one is temperature value ( double ) and the other is a type (char ) indicating 'F' or 'f' for the Fahrenheit scale or 'C' or 'c' for the Celsius scale.
Your class should have only the following methods:
Your class should have four constructors. One constructor should be the default constructor which will set the default temperature type to 'C'.
There should be three set methods for setting or resetting one or both of the data members. Names of these three methods should be set.
There should be one method named isCelsius which returns
true if the scale is Celsius and false otherwise.
There should be one method to take user input. Input temperature value may be a negative or non negative double number.
Do error checking on temperature type. The program should NOT exit if a character other than 'F' (or 'f') or 'C' (or 'c') is entered, but should force the user to enter a valid character.
There should be one output method to output both the data
members with appropriate message. The temperature value
should be displayed with only one digit after the decimal
point ( if required, you may use Math class or Format class. )
There should be one method named getFahrenheit which
returns the temperature in degrees Fahrenheit. Similarly there should be a method named getCelsius which returns the
temperature in degrees Celsius. ( Note that temperature might have been entered in any units 'F' or 'C', so you may need to do the conversion from one type to another. )
There should be three methods for comparing two temperature values. One for comparing equality, the second for less than and the third for greater than. These methods should return true or false depending on whether the two temperature values being compared are equal, one is less than the other, or one is greater than the other.
Write a demo class named demoTemperature which will
demonstrate use of the above methods. The demo class will ask the user to input two temperatures, and then will test the above methods using these two temperatures. The demo class should run EXACTLY as follows (pay special attention to order of input/output), with the only difference being the numbers that are inputted (they are just a sample):
---Testing input methods---
Inputting first temperature...
Input temperature: 212
Input scale (f/c): f
Inputting second temperature...
Input temperature: 120
Input scale (f/c): d
Invalid scale!
Input scale (f/c): c
---Testing output methods---
Outputting first temperature...
212.0 degrees Fahrenheit
Outputting second temperature...
120.0 degrees Celsius
---Testing conversion methods---
Converting first temperature...
212.0 degrees Fahrenheit is 100.0 degrees on the Celsius scale
Converting second temperature...
120.0 degrees Celsius is 248.0 degrees on the Fahrenheit scale
---Testing equality method---
212.0 degrees Fahrenheit
IS NOT EQUAL TO
120.0 degrees Celsius
---Testing greater than method---
212.0 degrees Fahrenheit
IS NOT GREATER THAN
120.0 degrees Celsius
---Testing less than method---
212.0 degrees Fahrenheit
IS LESS THAN
120.0 degrees Celsius
Please if any one can can help me out I would appreciate it a lot. Thank-You!!!