KnowledgeBoat Logo

Computer Applications

Write a program in java to input the temperature in Fahrenheit, convert it into Celsius and display the value in the Terminal window. A sample output is displayed below:

Enter temperature in Fahrenheit
176
176.0 degree Fahrenheit = 80.0 degree Celsius

Java

Input in Java

58 Likes

Answer

import java.util.Scanner;

public class KboatTemperature
{
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        System.out.println("Enter temperature in Fahrenheit: ");
        double f = in.nextDouble();
        double c = (f - 32) * 5.0 / 9.0;
        System.out.println(f + " degree Fahrenheit = " + c + " degree Celsius");
    }
}

Output

BlueJ output of Write a program in java to input the temperature in Fahrenheit, convert it into Celsius and display the value in the Terminal window. A sample output is displayed below: Enter temperature in Fahrenheit 176 176.0 degree Fahrenheit = 80.0 degree Celsius

Answered By

24 Likes


Related Questions