Java program to convert the temperature from Celsius to Fahrenheit. In a similar way, we can also write Java program to convert the temperature from Fahrenheit to Celsius.
The formula that will be used for this problem is,
⁰C = ( 5 / 9 ) * ( ⁰F – 32 )


Convert Fahrenheit to Celsius in Java Language (updated)
import java.util.Scanner;
public class TemperatureConversion {
// method to convert fahrenheit to celsius
public static double toCelsius(double fahrenheit){
return ((5.0/9.0) * (fahrenheit - 32));
}
public static void main(String[] args) {
// declare variables
double celsius = 0.0;
double fahrenheit = 0.0;
// create Scanner class object
Scanner scan = new Scanner(System.in);
// read input
System.out.print("Enter Fahrenheit value::");
fahrenheit = scan.nextDouble();
// convert temperature
celsius = toCelsius(fahrenheit);
// display result
System.out.format("Celsius value = %.2f",
celsius);
// close Scanner class object
scan.close();
}
}
OUTPUT
Enter Fahrenheit value:: 98
Celsius value = 36.67
Types of Sorting Algorithms:
Additional Reading
- SEO Practices Everyone Should Follow SEO Rules
- Complete Top SEO Checklist
- Yoast Seo Premium 15.2 Nulled – WordPress SEO Plugin
- Top 50+ SEO Interview Questions
- What is a Backlink? How to Get More Backlinks
READ MORE
If you found this post useful, don’t forget to share this with your friends, and if you have any query feel free to comment it in the comment section.
Thank you 😊 Keep Learning !