Example 5.2
//pag 49 http://www.greenteapress.com/thinkapjava/thinkapjava.pdf
 
public class example_5_2    
{
 
    public static double distance(double x1, double y1, double x2, double y2) {
        double dx = x1 - x2;
        double dy = y1 - y2;
        double result = Math.sqrt(Math.pow(dx,2) + Math.pow(dy,2));
        return result;
    }
 
    public static void main(String [] args) {
        double dist = distance(1.0, 2.0, 4.0, 6.0);
        System.out.println(dist);
    }
}

voltar

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.