- 5th Jun 2019
- 04:33 am
- Admin
This program takes the temperature in Celsius as input from the user and converts it to Fahrenheit using the formula (Celsius * 9 / 5) + 32
. The result is then displayed on the console.
import java.util.Scanner;
public class CelsiusToFahrenheit {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter temperature in Celsius: ");
double celsius = sc.nextDouble();
double fahrenheit = (celsius * 9 / 5) + 32;
System.out.println("Temperature in Fahrenheit: " + fahrenheit + " °F");
}
}