Monday 23 March 2020

CONVERTING CELSIUS TO FAHRENHEIT USING JAVA LANGUAGE

Q-14-Write a java program that reads a Celsius degree in a double value from the console, then converts it to Fahrenheit and displays the result. The formula for the conversion is as follows:                                                        fahrenheit = (9 / 5) * celsius + 32

INPUT :
import java.util.Scanner;
public class NCM {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
double celsius;
System.out.println("Enter The Degree In Celsius :");
celsius=sc.nextDouble();
double fahrenheit=((9.0/5.0)*celsius)+32;
System.out.println(celsius+" Celsius Is "+fahrenheit+" Fahrenheit");
}


}

OUTPUT :
Enter The Degree In Celsius :
43

43.0 Celsius Is 109.4 Fahrenheit

No comments:

Post a Comment