Celsius to Fahrenheit conversion program in Java

Celsius to Fahrenheit conversion program in Java

In this tutorial, you will be learning to write Java Program to convert temperature from Celsius to Fahrenheit.

For example:

Suppose we have a given temperature in Celsius 36

Now conversion in Fahrenheit

Formula to convert Celsius to Fahrenheit

(celsius * 9 / 5) + 32

(36 * 9 / 5) + 32 = 96.8 Fahrenheit

Java Program to convert temperature from Celsius to Fahrenheit

import java.util.*;
public class Main
{
    public static void main(String[] args) {
        float celsius, fahrenheit;
        System.out.println("Java Program to convert Celsius to Fahrenheit");
        Scanner sc = new Scanner(System.in);
        System.out.println("Give Temperature in Celsius");
        celsius= sc.nextFloat();
        fahrenheit = (celsius * 9 / 5) + 32;
        System.out.printf("Temp in Fahrenheit = %.2f",fahrenheit);
    }
}

Output 1:

Java Program to convert Celsius to Fahrenheit
Give Temperature in Celsius
36.6
Temp in Fahrenheit = 97.88