Question: Write a class that contains the following three methods ( 1 8 Points ) : / * * Convert from Celsius to Fahrenheit * /
Write a class that contains the following three methods Points:
Convert from Celsius to Fahrenheit
public static double celsiusToFahrenheitdouble celsius
Convert from Fahrenheit to Celsius
public static double fahrenheit ToCelsiusdouble fahrenheit
Print conversion result public void printConversionString conversionType, double value
The formulas for the conversions are:
Fahrenheit Celsius
Celsius Fahrenheit
Instructions:
The printConversion method should take a string celsius ToFahrenheit" or "fahrenheitToCelsius" to specify the type of conversion and a value for conversion, then print the result.
For example:
If the input is "celsius ToFahrenheit" and value it should print degrees Celsius is degrees Fahrenheit.
If the input is "fahrenheit ToCelsius" and value it should print degrees Fahrenheit is degrees Celsius.
If the input is neither "celsius ToFahrenheit" nor "fahrenheit ToCelsius", it should print Imalid conversion type. Please use
celsius ToFahreheit' or yahrenheitToCelsius
Write a main method to test your code by performing the following tasks you don't need to take inputs from the user: Points
Convert degrees Celsius to Fahrenheit and print the result.
Convert degrees Fahrenheit to Celsius and print the result.
Test with an invalid conversion type and print the appropriate message.
Expected output:
degrees Celsius is degrees Fahrenheit.
degrees Fahrenheit is degrees Celsius.
Invalid conversion type. Please use 'celsius ToFahrenheit' or 'fahrenheit ToCelsius'
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
