Temperature of a city in Fahrenheit degree is input through the keyboard. Write a program to convert this Fahrenheit degree into centigrade degree
Here’s a simple Java program that takes temperature in Fahrenheit as input and converts it to Celsius (Centigrade) using the formula:
> Celsius = (Fahrenheit – 32) × 5 / 9
—
✅ Java Code:
import java.util.Scanner;
public class TemperatureConverter {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Input temperature in Fahrenheit
System.out.print(“Enter temperature in Fahrenheit: “);
double fahrenheit = scanner.nextDouble();
// Convert to Celsius
double celsius = (fahrenheit – 32) * 5 / 9;
// Display result
System.out.println(“Temperature in Celsius: ” + celsius);
scanner.close();
}
}
—
📝 Sample Input/Output:
Enter temperature in Fahrenheit: 98.6
Temperature in Celsius: 37.0