In: Computer Science
In Java:
Write a program called F2C that allows the user to convert from degrees Fahrenheit to degrees Celsius. The program should prompt for a temperature in Fahrenheit and output a temperature in Celsius. All calculations should be done in in ints, so be careful of truncation.
Code Screenshot :
Executable Code:
//Scanner for user input
import java.util.Scanner;
public class F2C {
public static final void
main(String[] args) {
Scanner scan =
new Scanner (System.in);
int
celcuis,fahrenheit;
//Prompting the user for input
System.out.print("Fahrenheit: ");
//Reading the input
fahrenheit = scan.nextInt();
//Converting farenheit to celcius
celcuis = (fahrenheit-32)*5/9;
//Printing the result
System.out.println("Celcius: "+celcuis);
}
}
Sample Output :
Please comment
below if you have any queries.
Please do give a thumbs up if you liked the answer thanks
:)