5.5k views
3 votes
write a program in JAVA Create an interface with the name "Calculate." In this interface, declare two methods (signatures only) with the names "calculateArea()" and "getSides()."Create three new classes: Triangle, Rectangle, and Square. Use the "calculateArea()" and "getSides()" methods in both classes to calculate and print the area of all the shapes and also print the number of sides for that respective shape

User Erin Geyer
by
7.8k points

1 Answer

3 votes

Final answer:

To solve this task, create an interface called "Calculate" with two methods, and then implement those methods in the Triangle, Rectangle, and Square classes to calculate and print the areas of the respective shapes.

Step-by-step explanation:

In Java, you can create an interface called "Calculate" and declare two methods within it: "calculateArea()" and "getSides()". These methods will be implemented by three different classes: Triangle, Rectangle, and Square. In each of these classes, you can use the implemented methods to calculate and print the area of the shape and also print the number of sides for that shape.

User Thewisegod
by
7.0k points