Respuesta :

Answer:

//import the Scanner class to allow for user's input

import java.util.Scanner;

//Create a class declaration with appropriate name

public class FahrenheitToCelsius {

   //Begin the main method where execution starts from

   public static void main(String[] args) {

       //Create an object of the Scanner class to allow reading from standard

       // input

       Scanner input = new Scanner(System.in);

       

       //Prompt the user to enter the temperature

       System.out.println("Enter a temperature in Fahrenheit degrees");

       

       //Read the number and store in a variable of type double

       double fahrenheit = input.nextDouble();

       

       

       //Convert the temperature to Celsius

       double celsius  = (fahrenheit - 32) * (5 / 9.0);

       

       //Print out the result

       System.out.println("The temperature in Celsius is " + celsius);

       

   } //End of main method

   

}   //End of class declaration

==============================================================

Sample Output 1:

>> Enter a temperature in Fahrenheit degrees

32

>> The temperature in Celsius is 0.0

==============================================================

Sample Output 2:

>> Enter a temperature in Fahrenheit degrees

78

>> The temperature in Celsius is 25.555555555555557

===============================================================

Explanation:

The code has been written in Java and it contains comments explaining every segment of the code. Please go through the comments.

The actual lines of code are written in bold face to separate them from the comments.

Sample outputs have also been given to show how the result of the program looks like.