// Clase Principal
package pckpunto;
import java.io.*;
public class Principal {
public static InputStreamReader Leer=new InputStreamReader(System.in);
public static BufferedReader Teclado=new BufferedReader(Leer);
public static void main(String[] args) throws IOException {
System.out.println("Ingrese x1 ");
int p1=Integer.parseInt(Teclado.readLine());
System.out.println("Ingrese x2 ");
int p2=Integer.parseInt(Teclado.readLine());
System.out.println("Ingrese y1 ");
int d1=Integer.parseInt(Teclado.readLine());
System.out.println("Ingrese y2 ");
int d2=Integer.parseInt(Teclado.readLine());
//Creo el Objetoo
punto punt=new punto(p1,p2,d1,d2);
double tot=punt.tot(d1,d2,p1,p2);
System.out.println(tot);
}
}
//Clase Punto
package pckpunto;
public class punto {
private int x1;
private int x2;
private int y1;
private int y2;
public punto (int x1,int x2,int y1,int y2){
this.x1=x1;
this.x2=x2;
this.y1=y1;
this.y2=y2;
}
public double tot (int x1,int x2,int y1,int y2 ){
double tot;
double dis1,dis2;
dis1=this.x2-this.x1;
dis2=this.y2-this.y1;
dis1=Math.pow(dis1,2)+Math.pow(dis2,2);
tot=Math.sqrt(dis1);
return tot;
}
}
No hay comentarios:
Publicar un comentario