Java Online Compiler
Example: Convert Celsius into Fahrenheit in Java Program
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// Convert Celsius into Fahrenheit in Java Program 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 Celsius::\n"); float c = in.nextFloat(); float f; // c = celsius, f = fahrenheit // It will convert the celsius into fahrenheit f = (float)((c * 9 / 5) + 32); // It will print the final output System.out.println(c + " Celsius = " + f + " Fahrenheit"); } }
7
Output
Clear
ADVERTISEMENTS