Simple program to convert temperature from Fahrenheit to celcius:
//********************************************************************
// TempConverter.java
// Convert Fahrenheit (°F) to Celcius (°C)
//********************************************************************
import java.util.Scanner;
public class TempConverter
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
Scanner scan = new Scanner (System.in);
System.out.println ("Please enter Fahrenheit (°F) : ");
double fahrenheit;
fahrenheit = scan.nextDouble();
double celsius = (fahrenheit-32) * 5 / 9;
System.out.println ("Celcius (°C) = " + celsius + " °C");
}
}
No comments:
Post a Comment