Fahrenheit To Celsius Java Program


This program is to convert Fahrenheit to Celsius temperature based on user input value. Below is mathematical formula for conversion from Fahrenheit to Celsius temperature .

T = 9*T/5 + 32 where T is temperature on Celsius scale.

import java.util.Scanner;

class FahrenheitToCelsius {
	  public static void main(String[] args) {
	    float temperatue;
	    Scanner in = new Scanner(System.in);      

	    System.out.println("Enter Temperatue in Fahrenheit");
	    temperatue = in.nextInt();

	    temperatue = ((temperatue - 32)*5)/9;

	    System.out.println("Converted Temperatue in Celsius = " + temperatue);
	  }
	}

Outout

Enter Temperatue in Fahrenheit
100
Converted Temperatue in Celsius = 37.77778

Enter Temperatue in Fahrenheit
50
Converted Temperatue in Celsius = 10.0

Enter Temperatue in Fahrenheit
75
Converted Temperatue in Celsius = 23.88889

More

For more Algorithms and Java Programing Test questions and sample code follow below links

 

Advertisements

One thought on “Fahrenheit To Celsius Java Program”

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s