Saturday, February 7, 2026
HomeLanguagesJavaJava Program to Convert Celsius into Fahrenheit

Java Program to Convert Celsius into Fahrenheit

Celsius scale is a temperature scale that is based on the freezing point of water at 0 °C and the boiling point of water at 100 °C. Fahrenheit scale is a temperature scale that has a freezing point of water at 32 °F and the boiling point of water at 212 °F.

Examples:

Input : 0
Output: 32
Input :-40
Output:-40

 fahrenheit=(celsius*1.8)+32

Approach:

  1. Initializing value of celsius as 10.0 and Fahrenheit value as 0.0
  2. Calculate the Fahrenheit using the below formula
  3. Fahrenheit=(celsius*1.8)+32;
  4. Display Fahrenheit.

Below is the implementation of the above approach:

Java




// Java Program to Convert Celsius into Fahrenheit
class celsiustofahrenheit {
    public static void main(String[] args)
    {
        // initialising
        double celsius = 10.0, fahrenheit = 0.0;
        
        // formula for conversion
        fahrenheit = (celsius * 1.8) + 32;
        System.out.println(
            " value of temperature in fahrenheit:"
            + fahrenheit);
    }
}


Output

 value of temperature in fahrenheit:50.0

Time Complexity: O(1)

Space Complexity: O(1)

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32491 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6863 POSTS0 COMMENTS
Nicole Veronica
11987 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12077 POSTS0 COMMENTS
Shaida Kate Naidoo
6996 POSTS0 COMMENTS
Ted Musemwa
7238 POSTS0 COMMENTS
Thapelo Manthata
6947 POSTS0 COMMENTS
Umr Jansen
6934 POSTS0 COMMENTS