13. Write a program in java to input the temperature in Fahrenheit, convert it into Celsius and display the value in the
Terminal window.
Answers
Answered by
2
Question:-
- Write a program in java to input the temperature in Fahrenheit, convert it into Celsius and display the value in the Terminal window.
_____
Code:-
package Coder;
import java.util.*;
public class Temp {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Temperature in Fahrenheit?");
double f=sc.nextDouble();
double c=((f-32)/9)*5;
System.out.println(f+"°F="+c+"°C");
}
}
_____
Variable Description:-
- f:- To Accept input of temperature in Fahrenheit.
- c:- To store the converted temperature.
______
•Output Attached
Attachments:
Answered by
2
import java.util.Scanner;
public class TemperatureConversion {
public static void main(String[ ] args) {
System.out.print("Enter temperature in Fahrenheit - ");
float fahrenheit = new Scanner(System.in).nextFloat( );
System.out.println("Celsius - " + ((fahrenheit - 32) * 5 / 9));
}
}
Similar questions