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
63 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
Answered By
26 Likes
Related Questions
Explain the following terms, giving an example of each.
i. Syntax error
ii. Runtime error
iii. Logical error
Write a program in Java that accepts the seconds as input and converts them into the corresponding number of hours, minutes and seconds. A sample output is shown below:
Enter Total Seconds: 5000 1 Hour(s) 23 Minute(s) 20 Second(s)
A program has compiled successfully without any errors. Does this mean the program is error free? Explain.
Write a program in Java that uses 'input using initialisation' to calculate the Simple Interest and the Total Amount with the given values:
i. Principle Amount = Rs. 20000
ii. Rate = 8.9%
iii. Time = 3 years