Point Berpotongan

 Assalamualaikum, . .
Kali ini saya akan membagikan tentang point berpotongan pada pemrograman java, . .

import java.util.Scanner;

public class IntersectingPoint {
   
    public static void main(String[] iriahus) {
        @SuppressWarnings("resource")
        Scanner s = new Scanner(System.in);
       
        System.out.print("Enter x1, y1, x2, y2, x3, y3, x4, y4: ");
        double x1 = s.nextDouble();
        double y1 = s.nextDouble();
        double x2 = s.nextDouble();
        double y2 = s.nextDouble();
        double x3 = s.nextDouble();
        double y3 = s.nextDouble();
        double x4 = s.nextDouble();
        double y4 = s.nextDouble();
       
        double a, b, c, d, e, f;
            a = y1 - y2;
            b = x1 - x2;
            c = y3 - y4;
            d = x3 - x4;
            e = a * x1 - b * y1;
            f = c * x3 - d * y3;
           
        double x = (e * d - b * f) / (a * d - c * b);
        double y = (a * f - e * c) / (a * d - c * b);
       
        if ((a * d - c * b) != 0)
            System.out.println("The intersecting points is (" + x + ", " + y +")");
        else
            System.out.println("The two lines are parallel");     
       
       
    }

}

Semoga Bermanfaat. . .

Subscribe to receive free email updates:

0 Response to "Point Berpotongan "

Post a Comment