Question: JAVA : Use the classes we wrote for temperature conversion (F to C and C to F) and the class you wrote for wind chill

JAVA :

Use the classes we wrote for temperature conversion (F to C and C to F) and the class you wrote for wind chill temperature to provide the following functionality:

Write a driver that allows the user to enter a temperature in either Celsius or Fahrenheit and then prints the temperature value in Fahrenheit, and Celsius along with the wind chill index.

Allow the user to change the value of the temperature (either scale) and the speed of the wind in miles per hour. Then display the same information anytime the user changes a value.

Allow the user to continue changing values until they enter a q or Q to quit

Create only ONE instance of the WindChill class and one instance of the TemperatureConversion class. After that, call the appropriate set( ) methods.

Validate user input for the following input: Allow only:

T or t to change temperature S or s to change wind speed F or f for Fahrenheit C or c for Celsius

To earn full credit:

The project must be submitted to Canvas before the due time or the project earns a zero.

The project must compile or the project earns a zero.

Points will be assigned for correctness, ease of use, data validation as stated above, proper use of a loop, proper calling of set( ) methods and the toString( ) methods.

At least 20 will be assigned for full Javadoc documentation, following the coding conventions we discussed in class, liberal use of inline comments and program readability.

Temperature conversion

____________________________

public class Temperature

{

private double celciusTemperature;

private double fahrenheitTemperature;

//the constructor method has the same exact name

//as the class and there is NO return type

//The constructor method is used to "construct"

//an object

public Temperature( )

{

celciusTemperature = 0;

fahrenheitTemperature = 32;

}

//mthos with the same name but with

//different formal paramter lists can coexist

//This is call overloading a method

public Temperature(double inTemp, char scale )

{

if(scale == 'C' || scale == 'c')

{

celciusTemperature = inTemp;

fahrenheitTemperature = (9.0/5 * celciusTemperature) + 32;

}

else

{

fahrenheitTemperature = inTemp;

celciusTemperature = (fahrenheitTemperature - 32) * 5.0/9;

}

}

public void setCelcius(double inTemp)

{

celciusTemperature = inTemp;

fahrenheitTemperature = (9.0/5 * celciusTemperature) + 32;

}

public void setFahrenheit(double inTemp)

{

fahrenheitTemperature = inTemp;

celciusTemperature = (fahrenheitTemperature - 32) * 5.0/9;

}

public double getFahrenheitTemperature( )

{

return fahrenheitTemperature;

}

public double getCelciusTemperature( )

{

return celciusTemperature;

}

public String toString( )

{

return "Celcius is " + celciusTemperature + " Fahrenheit is "

+ fahrenheitTemperature ;

}

}

___________________________

Windchill class

____________________________

public class Windchill

{

private double temperatureInFahr;

private double windspeed;

private double windChillIndex;

public Windchill( )

{

temperatureInFahr = 32;

windspeed = 0;

windChillIndex = 32;

}

public Windchill(double inTemperature, double inWindSpeed)

{

temperatureInFahr = inTemperature;

windspeed = inWindSpeed;

if(temperatureInFahr < 50 && windspeed > 3)

windChillIndex = 35.74 + (.6215 * temperatureInFahr) - (35.75 * Math.pow(windspeed, 0.16))

+ (.4275 * temperatureInFahr * Math.pow(windspeed, 0.16));

else

windChillIndex = temperatureInFahr;

}

public void setTemperature(double inTemperature)

{

temperatureInFahr = inTemperature;

if(temperatureInFahr < 50 && windspeed > 3)

windChillIndex = 35.74 + (.6215 * temperatureInFahr) - (35.75 * Math.pow(windspeed, 0.16))

+ (.4275 * temperatureInFahr * Math.pow(windspeed, 0.16));

else

windChillIndex = temperatureInFahr;

}

public void setWindSpeed(double inWindSpeed)

{

windspeed = inWindSpeed;

if(temperatureInFahr < 50 && windspeed > 3)

windChillIndex = 35.74 + (.6215 * temperatureInFahr) - (35.75 * Math.pow(windspeed, 0.16))

+ (.4275 * temperatureInFahr * Math.pow(windspeed, 0.16));

else

windChillIndex = temperatureInFahr;

}

public double getTemperatureInFahr( )

{

return temperatureInFahr;

}

public double getWindspeed( )

{

return windspeed;

}

public double getWindChillIndex( )

{

return windChillIndex;

}

public String toString( )

{

return "Fahernheit temperature: " + temperatureInFahr

+ " Wind speed in mph: " + windspeed

+ " Wind chill index: " + windChillIndex;

}

}

___________________________

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!