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

Q: 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 constructor, the accessors and mutators, and methods toString. 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. Write a client class to test all the methods in your class.

Note: Please use "Java" and use following class. Please Scanner method so that user can input diferent fahrenheit temperatures, then system will convert into celsius and mention the sky condition

public class Weather_Forcast {

private double temperature_f ;

private double temperature_c ;

private String sky_condition ;

//Constructor

publicWeather_Forcast ( double temperature_f_in , double temperature_c_in

, String sky_condition_in)

{

temperature_f = temperature_f_in ;

temperature_c = temperature_c_in ;

sky_condition = sky_condition_in ;

}

//Mutator or Set Method

public void setTemperature_F (double temperature_f_in)

{

temperature_f = temperature_f_in ;

}

public void setTemperature_C (double temperature_c_in )

{

temperature_c = temperature_c_in ;

}

public void setSky_condition ( String sky_condition_in)

{

sky_condition = sky_condition_in ;

}

//Accessor or get Method

public double getTemperature_F ()

{

returntemperature_f ;

}

public double getTemperature_C ()

{

return (5.0 / 9.0 ) * ( temperature_f - 32.0 );

}

public String getSky_condtion ()

{

returnsky_condition ;

}

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 Databases Questions!