Write a class called Thermometer
(Not rated)
(Not rated)
Write a class called Thermometer. The thermometer should have the following features:
- Return the current temperature in either C or F (conversion)
- Reset the temperature to zero (if the current scale is C) or 32 (if the current scale is F)
- Set the scale of the thermometer to either C or F
- Set the temperature
- Return the current scale
- Provide a copy constructor to make a copy of a Thermometer
All data members of your class should be private. You should include a constructor to initialize the Thermometer object to 0˚ C, as well as a constructor that accepts a temperature and scale to initialize to. You will also need a copy constructor.
Write a small program that uses your Thermometer object. The program should exercise each of the features listed above. You don’t need to do them in this order, but here’s an example:
- Create (instantiate) a Thermometer
- Show that the thermometer has been initialized correctly
- Set the scale to either F or C
- Set the temperature
- Display the temperature in the scale opposite of what you set earlier
- Make a copy of the first Thermometer
- Change the temperature on the copy and display the temperature on both original and copy
12 years ago
Solution
NOT RATED
Purchase the answer to view it
- thermometer.cpp