Menu
Question Index
...


Write a program to find if the given points form a square. Points are given in anti clock wise direction starting from bottom left point.

Input (Point, Point, Point, Point) Output (boolean)
[4, 5], [6, 5], [6, 7], [4, 7] true
[2, 2], [4, 2], [4, 4], [2, 4] true
[2, 1], [8, 1], [9, 8], [6, 6] false
[1, 0], [1, 2], [1, 3], [0, 2] false
[5, 2], [10, 2], [12, 5], [7, 5] false

class IsASquare

{    public static void main(String s[])
    {
        Point firstPoint = new Point(4, 5);
        Point secondPoint = new Point(6, 5);
        Point thirdPoint = new Point(6, 7);
        Point fourthPoint = new Point(4, 7);
        System.out.println("Is a square : " + isASquare(firstPoint, secondPoint, thirdPoint, fourthPoint));

    }


public static boolean isASquare(Point firstPoint, Point secondPoint, Point thirdPoint, Point fourthPoint) {
//Write code here to find if the given points form a square.
}

//If required write any additional methods here
}
class Point {

double x;
double y;

Point(double x, double y) {
this.x = x;
this.y = y;
}
}

Doubts

Problems

Topic: Java Multiple Methods In One Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App