• Lenguaje

    Java usando Scanner

  • Descripción

    Dada la ecuación general de la recta Ax + By + C = 0. Hacer un algoritmo que dados los parámetros A, B, C, y un punto en el plano cartesiano (x, y) identifique si el punto hace parte de la recta.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.Scanner;

public class RectaEnUnPuntoDelPlanoCartesiano {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double A, B, C, x, y;
        System.out.print("Ingresa el valor de A: ");
        A = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de B: ");
        B = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de C: ");
        C = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de x: ");
        x = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de y: ");
        y = in.nextDouble();
        in.nextLine();
        if(A*x+B*y+C==0)
            System.out.println("S\u00ED pertenece a la recta.");
        else
            System.out.println("No pertenece a la recta.");
    }

}