Java program to convert Celsius to Fahrenheit using Scanner
Java program to convert Celsius to Fahrenheit:
We develop a Java program to convert Celsius to Fahrenheit. The formula used to convert from Celsius to Fahrenheit is given as ⁰F= (⁰C * 9/5) + 32.
import java.util.Scanner; public class Celsius_Fahrenheit { private static double tofahrenheit(double celsius){ return ( celsius * (9.0/5.0) + 32 ); } public static void main(String[] args) { double celsius = 0.0; double fahrenheit = 0.0; Scanner scan = new Scanner(System.in); System.out.print("Enter the Celsius temperature value = "); celsius = scan.nextDouble(); fahrenheit = tofahrenheit(celsius); System.out.println("Fahrenheit temperature value = " +fahrenheit); scan.close(); } }
Output-1:
Output-2: