Java program to convert celsius to fahrenheit: Practice Java programming from home without using any fancy software just by tapping on this Simple Java Programs for Beginners tutorial.
Java Program to Convert Celsius to Fahrenheit
- Java program to convert temperature from Celsius to Fahrenheit.
- Write a java program to convert temperature from Celsius to Fahrenheit.
In this java program, we have to convert celsius temperature to fahrenheit temperature scale. We will first take a celsius temperature as input from user and then convert it to fahrenheit temperature and print it on screen.
For Example,
40 Celsius is equal to 104 Fahrenheit
- Celsius is a temperature scale where 0 °C indicates the melting point of ice and 100 °C indicates the steam point of water.
- Fahrenheit temperature scale was introduced around 300 years ago and is currently used in US. The boiling point of water is 212 °F and the freezing point of water is 32 °F.
Given a temperature in celsius, we can convert to fahrenheit scale using following equation.
where, C is the temperature in Celsius and F is temperature in Fahrenheit.
Java program to convert celsius to fahrenheit temperature

package com.tcc.java.programs;
import java.util.Scanner;
/**
* Java Program to convert temperature from
* Celsius to Fahrenheit
*/
public class CelsiusToFahrenheit {
public static void main(String args[]) {
double celsius, fahren;
Scanner scanner;
scanner = new Scanner(System.in);
// Take temperature in Celsius as input from user
System.out.println("Enter Temperature in Celsius");
celsius = scanner.nextFloat();
fahren = (9.0 / 5.0) * celsius + 32;
System.out.print("Temperature in Fahrenheit = " + fahren);
}
}
Output
Enter Temperature in Celsius 100 Temperature in Fahrenheit = 212.0
Enter Temperature in Celsius 0 Temperature in Fahrenheit = 32.0