Question: 3 . Program 3 , Square, will implement a data type Square that represents squares with the x and y coordinates of their upper -

3. Program 3, Square, will implement a data type Square that represents squares with the x and y coordinates of their upper-left corners and the length.The API should be as follows.Square(double x, double y, double length)//constructordouble area()//returns the area of the squaredouble perimeter()//returns the perimeter of the squareboolean intersects(Square b)//does this square intersect b? Two squares would intersect if they share one or more common pointsboolean contains(Square b)//does this square contain b?void draw()//draw this square on standard drawingNote: The program should include a main method to test that it does the following.* Instantiate a Square object whose upper-left corner coordinates and length are given as command-line arguments. It should print out the area and perimeter of the square.* Prompt the user for a second squares upper-left corner coordinates and length, and indicate whether it intersects with the square specified earlier and also whether it contains the square specified earlier.* Provide a pop-up window that displays the two squares.A sample run would be as follows.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!