0

How do i fix this illegal start of expression

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

15th Sep 2022, 8:41 AM
Mark Angelo Alarcon
Mark Angelo Alarcon - avatar
8 Answers
+ 1
Remove the extra multiplication operator: import java.util.Scanner; abstract class Shape { int width; abstract void area(); } //your code goes here class Square extends Shape{ public int area2; public Square(int x) { width=x; } public void area() { area2=width*width; System.out.println(area2); } } class Circle extends Shape{ public double area1; public Circle(int y) { width=y; } public void area() { area1=Math.PI*width*;👈 System.out.println(area1); } } 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(); } }
15th Sep 2022, 9:16 AM
Solo
Solo - avatar
+ 1
why are you using * after width ?? area1=Math.PI*width*; //area1=Math.PI*width;
15th Sep 2022, 9:17 AM
Davinder Kumar
Davinder Kumar - avatar
+ 1
Thanks
15th Sep 2022, 10:00 AM
Mark Angelo Alarcon
Mark Angelo Alarcon - avatar
0
My test case 1 is wrong. Please help
15th Sep 2022, 10:18 AM
Mark Angelo Alarcon
Mark Angelo Alarcon - avatar
0
Describe the task.
15th Sep 2022, 10:24 AM
Solo
Solo - avatar
0
Yo solo i post another question please answer it there. Please
15th Sep 2022, 10:51 AM
Mark Angelo Alarcon
Mark Angelo Alarcon - avatar
0
Thank you guys so much. I finished java
15th Sep 2022, 10:53 AM
Mark Angelo Alarcon
Mark Angelo Alarcon - avatar