Celsius to Fahrenheit

Convert temperature from Celsius to Fahrenheit.

JavaBeginner
Java
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

We apply the conversion formula: F = (C × 9/5) + 32.