home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / javafile / ch02 / Convert.java < prev    next >
Encoding:
Text File  |  1998-12-14  |  743 b   |  31 lines

  1. /*
  2. Convert.class prints a short table of common conversion factors.
  3. */
  4.  
  5. class Convert {
  6.  
  7. /*
  8.  * Note that the main method must be defined as
  9. * public static void main (String []) to be called from
  10.  * the Java interpreter.
  11.  */
  12.  
  13. public static void main (String args[]) {
  14.    
  15.    double mi_to_km = 1.609;
  16.    double gals_to_l = 3.79;
  17.    double kg_to_lbs = 2.2;
  18.  
  19.    System.out.print ("1 Mile equals\t");   
  20. System.out.print (mi_to_km);
  21.    System.out.println ("\tKilometers");    
  22.  
  23.    System.out.print ("1 Gallon equals\t");
  24.    System.out.print (gals_to_l);
  25.    System.out.print ("\tLiters\n");        
  26.  
  27.    System.out.print ("1 Kilogram equals\t");
  28.    System.out.print (kg_to_lbs);
  29.    System.out.println ("\tPounds");
  30. }
  31. }