Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have to convert the temperature into Celcius or into Fahrenheit. We have to us

ID: 3762142 • Letter: I

Question

I have to convert the temperature into Celcius or into Fahrenheit. We have to use following functions to create the codes. Then, sort them following by their size.

1) degree: double

2) scale: char

+Temperature()

+Temperature(degree: double)

+Temperature(scale: char)

+Temperature(degree: double, scale: char)

+getDegreeInCelsius(): double

+getDegreeInFahrenheit(): double

+setDegree(degree: double): void

+setDegree(scale: char): void

+setDegree(degree: double, scale: char): void

+equals(obj: Temperature): boolean

+isLessThan(obj: Temperature): boolean

+isGreaterThan(obj: Temperature): boolean

1. getDegreeInCelsius will return the temperature’s degree in its equivalent Celsius degree. If the temperature’s scale is ‘C’, then the return value is temperature’s degree. If the temperature’s scale is ‘F’, the return value is calculated by the following formula: C = (F-32)*5/9. For example, if the temperature degree is 77 and scale is ‘F’, then the method will return 25 since (77-32)*5/9 = 25. For another example, if the temperature degree is 77 and scale is ‘C’, then the method will return 77.

2. getDegreeInFahrenheit will return the temperature’s degree in its equivalent Fahrenheit degree. If the temperature’s scale is ‘F’, then the return value is temperature’s degree. If the temperature’s scale is ‘C’, the return value is calculated by the following formula: F = 1.8C+32. For example, if the temperature degree is 25 and scale is ‘F’, then the method will return 25; For another example, if the temperature degree is 25 and scale is ‘C’, then the method will return 77 since 1.8*25+32 = 77.

3. void setDegree(double degree) will reset the temperature to given degree without change the scale of the temperature.

4. void setDegree(char scale) will reset the temperature to given scale without change the degree of the temperature.

5. void setDetree(double degree, char scale) will reset the temperature to given degree of given scale.

6. equals method returns true if this temperature is equal to parameter Temperature; false otherwise. You need to compare tow temperatures under same scale. For example, you either compare whether getDegreeInCelsius return same value for both temperatures, or whether getDegreeInFahrenheit return the same value for both temperatures.

7. isLessThan method return true if this temperature is less than parameter Temperature ; false otherwise. Again, you need to compare two temperatures under same scale.

8. isGreaterThan method returns true if this temperature is greater than parameter Temperature; false otherwise. Again, you need to compare two temperatures under same scale.

Temperature

1) degree: double

2) scale: char

+Temperature()

+Temperature(degree: double)

+Temperature(scale: char)

+Temperature(degree: double, scale: char)

+getDegreeInCelsius(): double

+getDegreeInFahrenheit(): double

+setDegree(degree: double): void

+setDegree(scale: char): void

+setDegree(degree: double, scale: char): void

+equals(obj: Temperature): boolean

+isLessThan(obj: Temperature): boolean

+isGreaterThan(obj: Temperature): boolean

Explanation / Answer

Output :