Package additional

Class TemperatureConverter

java.lang.Object
additional.TemperatureConverter

public class TemperatureConverter extends Object
Utility class for converting temperatures between Celsius and Fahrenheit. Can be used statically or instantiated with a specific temperature.
  • Constructor Details

    • TemperatureConverter

      public TemperatureConverter(double temperatureCelsius)
      Constructs a TemperatureConverter object with a specific temperature.
      Parameters:
      temperatureCelsius - the initial temperature in degrees Celsius
  • Method Details

    • celsiusToFahrenheit

      public static double celsiusToFahrenheit(double celsius)
      Converts a temperature from Celsius to Fahrenheit.
      Parameters:
      celsius - the temperature in degrees Celsius
      Returns:
      the converted temperature in degrees Fahrenheit
    • toFahrenheit

      public double toFahrenheit()
      Converts the stored Celsius temperature to Fahrenheit.
      Returns:
      the temperature in degrees Fahrenheit
    • setTemperature

      public void setTemperature(double newCelsius)
      Updates the stored temperature in Celsius.
      Parameters:
      newCelsius - the new temperature in degrees Celsius