Celsius To Fahrenheit Example Java Program

Formula

[°F] = [°C] * 9?5 + 32

where,
[°F] is the temperature in Fahrenheit scale
[°C] is the temperature in Celsius scale

Celsius To Fahrenheit Example Program

import java.util.Scanner;

public class CelsiusToFahrenheit {
    public static void main(String[] args) {
		System.out.println("Enter a temperature in Celsius: ");
		Scanner in = new Scanner(System.in);
		double Fahrenheit = 0;
		if(in.hasNextDouble()){
			Fahrenheit = (in.nextDouble() + 32)*9/5;
        }
        System.out.println("The temperature in Fahrenheit is: "+Fahrenheit);
    }
 
}

Sample Output

Output is:
Enter a temperature in Celsius:
115
The temperature in Fahrenheit is: 264.6