将加仑换算为升

尽管前面的几个程序说明了Java语言的几个重要特性,但是他们的额用处并不是很大.在本例中,我们将创建一个将加仑(gallon)换算为升(liter)的程序:
package javaTest;
public class test
{
    // @param args
    public static void main(String args[])
    {
        double gallon;
        double liter;
        
        gallon = 10.2;
        liter = gallon * 3.7854;
        
        System.out.println(gallon+" gallon = "+liter+" liter");
    }
}
输出:
10.2 gallon = 38.61108 liter