Practice with sealed interfaces

Report a typo

Implement the Square class and run the code.

Sample Input 1:

11.1

Sample Output 1:

123.21
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 interface ShapeInterface permits Square {
double getArea();
}

// Implement the Square class here
___

Create a free account to access the full topic