Question: Write a class encapsulating the concept of the weather forecast, assuming that it has the following attributes: the temperature and the sky conditions, which could

Write a class encapsulating the concept of the weather forecast, assuming that it has the following attributes: the temperature and the sky conditions, which could be sunny, snowy, cloudy, or rainy. Include a default constructor, an overloaded constructor, the accessors and mutators, and methods, toString() and equals(). Temperature, in Fahrenheit, should be between -50 and +150; the default value is 70, if needed. The default sky condition is sunny. Include a method that converts Fahrenheit to Celsius. Celsius temperature = (Fahrenheit temperature - 32) * 5/9. Also include a method that checks whether the weather attributes are consistent (there are two cases where they are not consistent: when the temperature is below 32 and it is not snowy, and when the temperature is above 100 and it is not sunny). Write a client class to test all the methods in your class.

   

Here is the outcome 

   

 

   

Problems Javadoc Declaration Console X Weather ForecastClient [Java Application] C:\Program Temperature cannot


Problems Javadoc Declaration Console X Weather ForecastClient [Java Application] C:\Program Temperature cannot be less than -50 or greater than 150. Temperature set to 70.0. The temperature of weather forecast #1 is 23.0F or -5.00 The sky condition of weather forecast #1 is sunny. Weather forecast #2 is temperature: 70.0; sky: cloudy. Files\Java\jre1.8.0_111\bin\javaw.exe (Jan 3, 2017, 12:45:46 PM) weather forecast temperature: 23.0; sky: sunny is not consistent weather forecast temperature: 70.0; sky: cloudy is consistent Original weather forecasts #1 and #2 are different. Original weather forecast #1 and modified weather forecast #2 are identical

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a Java class for the Weather Forecast and a client class to test it public class WeatherForecast private double temperature private String skyCo... View full answer

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!