Write a Java program to convert Celsius to Fahrenheit with an example. And the formula to convert the Fahrenheit = (1.8 * Celsius) + 32
package Remaining; import java.util.Scanner; public class CelsiusToFahrenheit { private static Scanner sc; public static void main(String[] args) { sc= new Scanner(System.in); System.out.print("Enter the Temperature in Celsius = "); double celsius = sc.nextDouble(); double fahrenheit = ((celsius * 9) / 5) + 32; //double fahrenheit = (1.8 * celsius) + 32; System.out.println("Temperature in Celsius = " + celsius); System.out.println("Temperature in Fahrenheit = " + fahrenheit); } }
Let me try different values in the above program.
Enter the Temperature in Celsius = 36
Temperature in Celsius = 36.0
Temperature in Fahrenheit = 96.8