In this tutorial, we will see simple java program to convert fahrenheit to celsius in java.
You can convert fahrenheit to celsius using this formula.
cel = (fh-32) / 1.8;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import java.util.Scanner; public class TempConvertor { public static void main(String args[]) { float fh; double cel; Scanner scanner = new Scanner(System.in); System.out.print("Enter Temperature in Fahrenheit : "); fh = scanner.nextFloat(); cel = (fh-32) / 1.8; System.out.print("Equivalent Temperature in Celsius : " + cel); } } |
Output:
Enter Temperature in Fahrenheit : 79
Equivalent Temperature in Celsius : 26.11111111111111
Equivalent Temperature in Celsius : 26.11111111111111
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.