Java Programs

Convert Celsius into Fahrenheit Program in Java

In this tutorial, We are going to learn a java program to convert Celsius into Fahrenheit. This program will be simple because we will use just a given formula of Celsius to Fahrenheit conversion. We have to Just apply this conversion formula in java programming.

How our Program will behave?

  1. Java program will take a temperature value from user in Celsius as a input.
  2. We will apply Celsius to Fahrenheit conversion formula which is (Celsius * 9 / 5)+32.
  3. This calculation result will be temperature in Fahrenheit.

Java Program to Convert Celsius into Fahrenheit

import java.util.*;

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

Output

Program to convert Celsius to Fahrenheit
Please give the Celsius Temperature
37
Fahrenheit = 98.60

Explanation

For the input Celsius temperature 37.

Fahrenheit temperature = (37 *9/5) + 32 = 98.60.

About the Author: Elavarasan PK

Technical Specialist, Intersoft Data Labs