import java.util.*;
public class quadrado {
public static void main (String args[]) {
int xp1,xp2,xp3,xp4,yp1,yp2,yp3,yp4;
double c1,c2,c3;
Scanner aa = new Scanner (System.in);
System.out.print("Insira a abcissa do P1\n");
xp1 = aa.nextInt();
System.out.print("Insira a ordenada do P1\n");
yp1 = aa.nextInt();
System.out.print("Insira a abcissa do P2\n");
xp2 = aa.nextInt();
System.out.print("Insira a ordenada do P2\n");
yp2 = aa.nextInt();
System.out.print("Insira a abcissa do P3\n");
xp3 = aa.nextInt();
System.out.print("Insira a ordenada do P3\n");
yp3 = aa.nextInt();
System.out.print("Insira a abcissa do P4\n");
xp4 = aa.nextInt();
System.out.print("Insira a ordenada do P4\n");
yp4 = aa.nextInt();
c1= Math.sqrt((xp2-xp1)^2 + (yp2-yp1)^2);
c2= Math.sqrt((xp3-xp2)^2 + (yp3-yp2)^2);
c3= Math.sqrt((xp4-xp3)^2 + (yp4-yp3)^2);
System.out.print("A figura é um quadrado: "+c1);
if (c1==c2==c3) { // sendo os lados consecutivos
System.out.print("A figura é um quadrado"); }
else {
System.out.print("A figura não é um quadrado"); }
}
}
I'm trying to write something that given the coordinates of 4 points decides if it forms a square. I decided to get the lenght of 3 vectors and, iff they are all the same size, it says it is a square. I'm a beginner so i really need help :/