+ 1

Failing only one test on Java: Shapes. Please help me.

Here is my solution: https://www.sololearn.com/learning/eom-project/1068/971 Only failing Case 3 for some reason. Code: import java.util.Scanner; //#region own code abstract class Shape { protected int width; abstract void area(); Shape(int w) { this.width = w; } } class Square extends Shape { Square(int w) { super(w); } final public void area() { System.out.println(this.width * this.width); } } class Circle extends Shape { Circle(int w) { super(w); } final public void area() { System.out.println(Math.PI * this.width * this.width); } } //#endregion 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(); } }

6th Jan 2021, 5:54 AM
SW8
SW8 - avatar
1 ответ
+ 2
Please save your code and reshare the link, or copy/paste your code directly. The link provided cannot be accessed
6th Jan 2021, 6:00 AM
Elizabeth Kelly
Elizabeth Kelly - avatar