Celsius to Fahrenheit
Convert temperature from Celsius to Fahrenheit.
BeginnerTopic: Module 1: Basic Java Programs
Java Celsius to Fahrenheit Program
This program helps you to learn the fundamental structure and syntax of Java programming.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter temperature in Celsius: ");
double c = sc.nextDouble();
double f = (c * 9 / 5) + 32;
System.out.println("Temperature in Fahrenheit = " + f);
sc.close();
}
}Output
Enter temperature in Celsius: 0 Temperature in Fahrenheit = 32.0
Understanding Celsius to Fahrenheit
We apply the conversion formula: F = (C × 9/5) + 32.
Note: To write and run Java programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Java Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Java programs.