Create a Java program that uses inheritance to calculate the…

Objective:

The goal of this assignment is to demonstrate a clear understanding of Object-Oriented Programming (OOP) principles in Java, specifically focusing on Inheritance and Method Overriding. You are required to design a program that manages different geometric shapes and calculates their areas using a common hierarchy.

Technical Requirements:

  1. Base Class: Create an abstract class named Shape. This class should contain:
    • A protected double variable to represent a primary dimension (like radius or side).
    • An abstract method double calculateArea().
  2. Subclasses: Implement at least two subclasses (e.g., Circle and Square) that extend the Shape class.
    • Each subclass must provide its own specific implementation of the calculateArea() method.
    • For Circle, use the formula: $Area = pi times r^2$.
    • For Square, use the formula: $Area = side times side$.
  3. Main Class: Include a Main or Driver class to instantiate these objects, set their dimensions, and print the calculated area to the console.

Requirements:

WRITE MY PAPER


Comments

Leave a Reply