title: basic java temperature converter
body: <p>So I am trying to write a program to convert degrees C to F or vice versa. Every time I run the program I am getting mistakes which I can't readily explain. For instance, it converts 100 C to 132 F. It converts 212 F to 0 C. My conversion formulas are right. Can anyone give me some clues? I tried declaring the floats in the class outside the main, but it didn't help.</p>
  
  <pre><code>import java.util.Scanner;
  public class TempConverter{
  public static void main(String [] args)
  {
      float f, c;
      f = c = 0;
      int a;
      Scanner scan = new Scanner (System.in);
      System.out.println("Press 1 for C-&gt;F or 2 for F-&gt;C");
      a = scan.nextInt();
      if (a == 1) 
          convertCtoFAndPrint();
      else
          convertFtoCAndPrint();
  }
  
  public static void convertFtoCAndPrint()
  {
      f = c = 0;
      Scanner scan = new Scanner (System.in);
      System.out.println("Please enter degrees F");
      f = scan.nextFloat();
      c = (5/9)*(f-32);
      System.out.println(f + " degrees F is " + c + " degrees C.");
  }
  
  public static void convertCtoFAndPrint()
  {
      Scanner scan = new Scanner (System.in);
      System.out.println("Please enter degrees C");
      c = scan.nextFloat();
      f = c*(9/5)+32;
      System.out.println(c + " degrees C is " + f + " degrees F.");
  }
  
  }
  </code></pre>