Write a complete program to compare the temperatures of three different cities and find the hottest city.

Question:

Write a complete program to compare the temperatures of three different cities and find the hottest city. First, implement a class called Thermometer as described below:
A. Thermometer has one private data member, temperature of type double.
B. Write code for a constructor to set a data member to the default value of 0.0 .
C. Write code for an accessor method, getTemperature, which returns the value of the appropriate data member.
D. Write code for a mutator method, setTemperature, which has one formal parameter, and store it as the value of the data member.
Then, write a client program to test the Thermometer class defined above. Call this class Temperatures. The main method should perform the following tasks:
E. Allow the user to enter the temperatures of three cities.
F. Declare and create three Thermometer objects setting the instance data member to the values entered by the user.
G. If city 1 is the hottest city among the three cities, output a phrase like "Cityl is the hottest city."
Here is some sample input and output:

image text in transcribed

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: