0
Pls rectify the errors and help me in correcting it
import java.util.Scanner; abstract class Shape { int width; abstract void area(); } class Square { Square(int width) { void area(){ System.out.println(width*width); } } } class Circle { Circle(int width) { void area() { System.out.println(Math.PI*width*width); } } } 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(); } }
2 Réponses
+ 5
See this code which I'm modified from your code
again learn carefully about abstract class ...
Below is my attempt 👇
https://code.sololearn.com/cezpFku341r7/?ref=app
+ 1
Thank you