ICSE Class 9 Computer Applications
Question 13 of 13
Input in Java — Question 13
Back to all questions 13
Question Question 13
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
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
