016-003-004
Polymorphism with Abstract Classes: Shape Calculator System
Hard
Problem Description
polymorphism with Abstract Classes: Shape Calculator System
In this problem, you will create a program that implements Circle and Triangle classes extending abstract class Shape, stores multiple shapes in a Shape array, calculates each area polymorphically, and displays the individual and total areas to standard output.
Learning Objective: Understand how to handle different shapes uniformly using polymorphism with abstract classes
Overview
Create Circle and Triangle extending abstract Shape class, store in array, and calculate areas polymorphically.
Specifications
- Shape (abstract): abstract double getArea() and String describe()
- Circle: Calculate area from radius (PI * r * r)
- Triangle: Calculate area from base and height (base * height / 2)
- Manage multiple shapes in Shape array and process with loop
Input
Shape type and parameters are provided
Output Format
Circle: area = 78.54
Triangle: area = 6.00
Total: 84.54
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up