0

What is wrong?

import java.util.Scanner; abstract class Shape { int width; abstract void area(); } class Square extends Shape { public void area(){ int area = width * width; System.out.println(area); } } class Circle extends Shape{ public void area(){ double area =Math.PI * width * width; System.out.println(area); } } //your code goes here 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(); } }

26th Nov 2020, 2:57 PM
Atharva Kulkarni
Atharva Kulkarni - avatar
3 Antworten
+ 3
You don't have a constructor for the classes you created. https://code.sololearn.com/cINx09DYdzT2/?ref=app
26th Nov 2020, 3:07 PM
Avinesh
Avinesh - avatar
0
It is showing error"Constructor Sqauare cannot be applied to class Sqare"
26th Nov 2020, 3:07 PM
Atharva Kulkarni
Atharva Kulkarni - avatar
0
Thanks💯💯
26th Nov 2020, 3:08 PM
Atharva Kulkarni
Atharva Kulkarni - avatar