Apply your OOP skills! Create a class hierarchy using inheritance and polymorphism to calculate areas of different shapes.
YOUR TASK
Create a program with:
An abstract class Shape with an abstract method area()
A Circle class (radius = 5) that extends Shape
A Rectangle class (width = 4, height = 7) that extends Shape
Print each shape's area using polymorphism
Need a hint?
Circle area = π × r² ≈ 78.54 (use Math.PI and round to 2 decimals with String.format("%.2f", ...))
Rectangle area = width × height = 28
Use abstract class Shape { abstract double area(); }
Expected Output:
Circle area: 78.54
Rectangle area: 28.0
Code Editor Ready
Output
Console
Console initialized...
Ready for Project 2: Shape Area Calculator
> Use abstract classes and inheritance to solve this
> Check your output matches the expected format exactly!