Sunday, 5 November 2017

java program that convert tempreatur into fahernhite



Problem 05:
Write a 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
Hint: In Java, 9 / 5 is 1, but 9.0 / 5 is 1.8.
Here is a sample run:
learn from examples
document analysis and design


Description:
Hint: In Java, 9 / 5 is 1, but 9.0 / 5 is 1.8.
Here is a sample run:
learn from examples
document analysis and design

Solution
 import java.util.*;
public class Message {
 public static void main(String[] args) {
   
Scanner Input = new Scanner(System.in);
System.out.println("Enter the temperature in Degree celcius");
float cel = Input.nextFloat();

   System.out.println("The temperatur in fahernhite is "+((9.0/5)*cel+32));
}
}

Output
                

No comments:

Post a Comment