Artem H.

asked • 05/07/21

Write a main program in a class called SquareMain.java that instantiates two square objects called s1 and s2.

Write a main program in a class called SquareMain.java that instantiates two square objects called s1 and s2.

Perform the following actions on s1 and s2 using methods of the Square class

Create s1 using the default constructor

Create s2 using the regular constructor with side = 4;

Calculate the area of s2 and print its value as follows:

"The area of square s2 is v" where v is value returned by the area method

Print the result of comparing s1 and s2 using the isSame method. This would print true if they are the same, print false otherwise

Change the size of square s1 to 6.

Print both squares using the toString method of the Square class


1 Expert Answer

By:

Patrick B. answered • 05/08/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.