Thursday, November 13, 2014

Temperature Conversion



import java.io.* ;
public class Temperature
{
      public static void fahToCelsius(double tempF)
      { 
      double tempC = (tempF - 32)/1.8 ;
      System.out.println("Temperature in Celsius is" + tempC) ;
      }
      public static void celToFahrenheit(double tempC 
      {
        double tempF = (tempC * 1.8) + 32 ;
 System.out.println("Temperature in Fahrenheit is" + tempF) ;
      }
 public static void main(String[ ] args)
      { System.out.println("1. Fahrenheit to Calcius") ;
 System.out.println("2. Celcius to Fahrenheit") ;
 System.out.println("Enter you choice") ;
 int ch = 0 ;
 DataInputStream in = new DataInputStream(System.in) ;
 double tmp ;
 System.out.println("Enter temperature to be converted") ;
      {
        if (ch == 1)
  fahToCelsius(tmp);
 else
  celToFahrenheit(tmp;
     }
}

No comments:

Post a Comment