Java Program to Convert Celsius to Fahrenheit

This post covers a program in Java that coverts a temperature in Celsius to its equivalent Fahrenheit value.

The formula to use, for Celsius to Fahrenheit conversion is:

F = (C * 1.8) + 32

where F is the temperature in Fahrenheit, whereas C is the temperature in Celsius.

Note - If you want to know, why this formula is used, then refer to Celsius to Fahrenheit Formula Explained.

Celsius to Fahrenheit Conversion in Java

The question is, write a Java program to convert Celsius to Fahrenheit. The Celsius value must be received by user at run-time of the program. The program given below is its answer:

import java.util.Scanner;

public class CodesCracker
   public static void main(String[] args)
      float celsius, fahrenheit;
      Scanner scan = new Scanner(;
      System.out.print("Enter the Temperature (in Celsius): ");
      celsius = scan.nextFloat();
      fahrenheit = (float) ((celsius*1.8)+32);
      System.out.println("\nEquivalent Temperature (in Fahrenheit) = " +fahrenheit);

The snapshot given below shows the sample run of above program with user input 37 as temperature in Celsius, to convert and print its equivalent Fahrenheit value:

java convert Celsius to Fahrenheit

Same Program in Other Languages

Java Online Test

« Previous Program Next Program »

Like/Share Us on Facebook 😋