Java Online Compiler
Example: Java program to convert the temperature from degree fahrenheit to celsius
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// Java program to convert the temperature from degree fahrenheit to celsius import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Enter the temperature in Fahrenheit::\n"); float f = in.nextFloat(); float c; // c = celsius // f = fahrenheit /* Convert celsius to fahrenheit */ c = (float)((f - 32) * 5 / 9); // Output System.out.print("\n"); System.out.println(f + " Fahrenheit = " + c + " Celsius"); } }
7
Output
Clear
ADVERTISEMENTS