Practice with sealed classes

Report a typo

Implement the Square class and run the code.

Sample Input 1:

8.5

Sample Output 1:

72.25
Write a program in Java 17
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.printf("%.2f", new Square(scanner.nextDouble()).getArea());
}
}

sealed abstract class Shape permits Square {
abstract double getArea();
}

// implement the Square class here
___

Create a free account to access the full topic