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 classes
Report a typo
Sample Input 1:
8.5Sample Output 1:
72.25Write 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
___
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.