014-005-002

Method Overriding: Shape Area Calculator

Easy

Problem Description

method Overriding: Shape Area Calculator

In this problem, you will create a program that overrides the getArea() method in Circle and Rectangle subclasses of Shape to calculate each shape's area and displays the result to standard output.

Learning Objective: override methods with return values

Create Shape class representing shapes and Circle/Rectangle classes inheriting from it. override getArea() method to implement each shape's area calculation formula.

Input

None (fixed values)

Output

Circle area: 78.54
Rectangle area: 24.00
```java

## Examples

### Example 1: Circle and rectangle areas
Input:
```java
(none)
```java
Output:
```java
Circle area: 78.54
Rectangle area: 24.00
```java

### Formulas
- Circle area: π × radius² (radius=5: 3.14159... × 2578.54)
- Rectangle area: width × height (width=4, height=6: 24.00).

Test Cases

※ Output examples follow programming industry standards

Input:
Expected Output:
Circle area: 78.54
Rectangle area: 24.00
Input:
Expected Output:
Circle area: 78.54
Rectangle area: 24.00
Input:
Expected Output:
Circle area: 78.54
Rectangle area: 24.00
Input:
Expected Output:
Circle area: 78.54
Rectangle area: 24.00
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
Shape.java🔒
Circle.java🔒
Rectangle.java🔒
Solution.java🔒
4/6 ファイル202B
public class Shape {
}
0 B / 5 MB

You have 7 free executions remaining