Computer Science, asked by ayush3027, 5 months ago

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 BrainlyProgrammer
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:-

  1. f:- To Accept input of temperature in Fahrenheit.
  2. c:- To store the converted temperature.

______

•Output Attached

Attachments:
Answered by Oreki
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