Source Code : Print a table of fahrenheit and celsius temperatures 2

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Print a table of fahrenheit and celsius temperatures 2

 


import java.text.*;

/* Print a table of fahrenheit and celsius temperatures, a bit more neatly.
 * @author Ian F. Darwin, http://www.darwinsys.com/
 * @version $Id: TempConverter2.java,v 1.6 2004/03/07 02:50:49 ian Exp $
 */
public class TempConverter2 extends TempConverter {
  protected DecimalFormat df;

  public static void main(String[] args) {
    TempConverter t = new TempConverter2();
    t.start();
    t.data();
    t.end();
  }

  // Constructor
  public TempConverter2() {
    df = new DecimalFormat("#0.00");
  }

  protected void print(float f, float c) {
    System.out.println(df.format(f) + " " + df.format(c));
  }

  protected void start() {
    System.out.println("Fahr    Centigrade.");
  }

  protected void end() {
    System.out.println("-------------------");
  }
}
class TempConverter {

  public static void main(String[] args) {
    TempConverter t = new TempConverter();
    t.start();
    t.data();
    t.end();
  }

  protected void start() {
  }

  protected void data() {
    for (int i=-40; i<=120; i+=10) {
      float c = (i-32)*(5f/9);
      print(i, c);
    }
  }

  protected void print(float f, float c) {
    System.out.println(f + " " + c);
  }

  protected void end() {
  }
}

           
         
  

Thank with us