Implement the Square class and run the code.
Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClasses and objectsClasses and members
Sealed classes and interfaces
Practice with sealed interfaces
Report a typo
Sample Input 1:
11.1Sample Output 1:
123.21Write 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
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.