Question: Instructions . Write a Temperature class that represents temperatures in degrees in both Celsius and Fahrenheit. Use a floating - point number for the temperature

Instructions
. Write a Temperature class that represents temperatures in degrees in both Celsius and Fahrenheit. Use a floating-point number for the temperature and a character for the scale: either 'C' for Celsius or 'F' for Fahrenheit. The class should have
Four constructors; one for the number of degrees, one for the scale, one for both the degrees and the scale, and a default constructor. For each of these constructors, assume zero degrees if no value is specified and Celsius if no scale is given.
Two accessor methods: one to retum the temperature in degrees Celsius, the other to return it in degrees Fahrenheit. Use the formulas from Programming Project 5 of Chapter 3 and round to the nearest tenth of a degree.
Three set methods: one to set the number of degrees, one to set the scale, and one to set both.
Three comparison methods one to test whether two temperatures are equal, one to test whether one temperature is greater than another, and one to test whether one temperature is less than another.
formulas needed --remember real/integer arithmetic
F=C95+32
C=(F-32)59
You will need a driver program to test this--you may use the one included, but it will not be the one used to grade the assignment I will use my own driver program to test it. the name of the class must me spelled this way-remember -case counts
Temperature
the method headers must be
float getCelsius()
float getFahrenheit()
void setTemp(float t)
void setScale(char s)
void setBoth(float t,char s)
boolean equals(Temperature t)
boolean greater(Temperature t)
boolean less(Temperature t)
constructor receiving temperature and scale must receive temperature and then scale
just submit your Temperature class file, not your test program,
Instructions . Write a Temperature class that

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!