JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.Scanner;
abstract class Shape {
int width;
abstract void area();
}
//your code goes here
class Square extends Shape{
public Square(int width){
this.width=width;
}
public void area(){
int result= (int)Math.pow(width,2);
System.out.println(result);
}
}
class Circle extends Shape{
public Circle(int width){
this.width=width;
}
public void area(){
// DO NOT use "Math.pow(width,2)*Math.PI" or the test case 3 will fail
double result= Math.PI*width*width;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run