Let’s start the discussion about Fahrenheit to celsius Program in following Approaches.
User-supplied temperature in degrees Fahrenheit. Store it in a variable, such as fahrenheit. Use the temperature conversion formula celsius = (fahrenheit – 32) * 5 / 9 to convert temperatures. Print the celsius temperature.
We use the below formulae for the conversions.
cels = (fahr - 32.0) * 5.0/9.0; //Fahr to cels
fahr = (cels * 9.0/5.0) + 32.0; //Cels to fahr
Contents
Program to convert from fahrenheit to celsius in Java
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int far = sc.nextInt();
int cel = (far - 32) * 5/9;
System.out.printf("%d Fahrenheit is %d Celsius", far, cel);
}
}
I hope the strategies listed above work for you. Happy coding and come back again.
Similar Post : invoke-webrequest download file