5-

1. Create a Square class. Create a class called Square. This class should have the following information stored in it:

double side

It should also implement the following functions(descriptions follow the function names):

void setSide(double) - The method takes one argument, a double, and stores it in the side variable. It returns nothing (void).

double getSide() - The method returns the value of the side variable as a double. It takes no arguments.

double getPerimeter() - The method returns the size of the Square's perimeter (which is equal to 4 * side) as a double. It takes no arguments.

double getArea() - The method returns the size of the Square's Area (which is equal to side * side) as a double. It takes no arguments.

boolean equals(Square)- This method returns True or false depending if the two squares are equal or not. It takes one argument of type Square.

Also create a test program to test the class and all of its functions. You should declare two squares, one of size 5 and one of size 7, display both of their perimeters and areas and then compare the two to see if they are equal. A good sample output of the program might be something like:

Square has size 5.0

Square has perimeter 20.0

Square has area 25.0

 

Square has size 7.0

Square has perimeter 28.0

Square has area 49.0

 

The two squares are not equal.