Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago