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(); } }

30th Nov 2022, 5:27 AM
Devishree
Devishree - avatar
2 Antworten
+ 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
30th Nov 2022, 6:07 AM
Sâñtôsh
Sâñtôsh - avatar
+ 1
Thank you
30th Nov 2022, 7:04 AM
Devishree
Devishree - avatar