Computer Science, asked by Anhad007, 7 months ago

Write a program in java to enter temperature in Fahrenheit and

convert it into Celsius.​

Answers

Answered by hazelblue9
1

Answer:

import java.util.Scanner;

public class Fahrenheit_Celsius

{

public static void main(String[] args)

{

double celsius, fahrenheit;

Scanner s = new Scanner(System.in);

System.out.print("Enter temperature in Fahrenheit:");

fahrenheit = s.nextDouble();

celsius = (fahrenheit-32)*(0.5556);

System.out.println("Temperature in Celsius:"+celsius);

}

}

Answered by anindyaadhikari13
2

Question:-

  • Write a program in java to enter a temperature in Fahrenheit and convert it into Celsius.

Code:-

 \sf\frac{C}{5}=\frac{F-32}{9}

 \sf \implies C=\frac{5(F-32)}{9}

Using this formula, we will calculate.

So, here is the code.

import java.util.*;

class Temperature

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

System.out.println("Enter the temperature in Fahrenheit Scale: ");

double f=sc.nextDouble();

double c=5*(f-32)/9.0;

System.out.println("Temperature in celsius is: "+c);

}

}

Similar questions