Abstract classes
Why would this not pass all the cases?!?! import java.util.*; import java.lang.*; abstract class Shape { int width; abstract void area(); } //your code goes here public class Square extends Shape { Square(int w) { width = w; } public void area(){ System.out.println(width*width); } } public class Circle extends Shape { Circle(int w) { width = w; } public void area(){ int sq = width*width; System.out.println(Math.PI*sq); } } public class Program { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); Square a = new Square(x); Circle b = new Circle(y); a.area(); b.area(); } }