Challenge: Utility Class for Temperature Conversion
Swipe to start coding
Create a static utility class named TemperatureConverter for temperature conversion. You must implement two static methods with the exact names:
-
CelsiusToFahrenheit: takes a Celsius temperature (double) and returns the corresponding Fahrenheit value (double). Use the formula:(celsius * 9 / 5) + 32. -
FahrenheitToCelsius: takes a Fahrenheit temperature (double) and returns the corresponding Celsius value (double). Use the formula:(fahrenheit - 32) * 5 / 9. -
The class must be declared as
static. -
Both methods must be declared as
staticand use the exact method names provided. -
Both methods must be accessible directly from the class without creating an instance.
-
Ensure you use the provided formulas for each conversion.
-
Do not change the method names or class name.
Løsning
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Can you explain this in simpler terms?
What are the main takeaways from this?
Can you provide an example to illustrate this?
Fantastisk!
Completion rate forbedret til 4.17
Challenge: Utility Class for Temperature Conversion
Sveip for å vise menyen
Swipe to start coding
Create a static utility class named TemperatureConverter for temperature conversion. You must implement two static methods with the exact names:
-
CelsiusToFahrenheit: takes a Celsius temperature (double) and returns the corresponding Fahrenheit value (double). Use the formula:(celsius * 9 / 5) + 32. -
FahrenheitToCelsius: takes a Fahrenheit temperature (double) and returns the corresponding Celsius value (double). Use the formula:(fahrenheit - 32) * 5 / 9. -
The class must be declared as
static. -
Both methods must be declared as
staticand use the exact method names provided. -
Both methods must be accessible directly from the class without creating an instance.
-
Ensure you use the provided formulas for each conversion.
-
Do not change the method names or class name.
Løsning
Takk for tilbakemeldingene dine!
single