+ 1

Student

The project in module 5 is not getting complete in java course. All the test cases are successful but the 3rd hidden case is not, please help.

8th Feb 2021, 2:27 PM
Aryan Gupta
Aryan Gupta - avatar
6 Réponses
0
Please post what you have tried
8th Feb 2021, 2:30 PM
Atul [Inactive]
0
See here's my code import java.util.Scanner; abstract class Shape { int width; abstract void area(); } //your code goes here class Square extends Shape { public Square(int w) { width = w; } public void area(){ // width = x; width *= width; System.out.println(width); } } class Circle extends Shape { public Circle(int w) { width = w; } public void area(){ double areaofCircle = (double) width * width * Math.PI; System.out.println(areaofCircle); } } public class ne { 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(); } }
9th Feb 2021, 2:34 PM
Aryan Gupta
Aryan Gupta - avatar
0
It's working fine. What's the problem?
9th Feb 2021, 2:38 PM
Atul [Inactive]
0
Yeah it's working perfectly fine but when I am running the same code in project of module 5 in java the 3rd test case fails while the other cases pass. Please help me.
11th Feb 2021, 4:28 AM
Aryan Gupta
Aryan Gupta - avatar
0
Can you tell me the name of that module?
11th Feb 2021, 5:56 AM
Atul [Inactive]
0
Ya, The name of the module is "More on Classes" and the project name is "Shapes".
11th Feb 2021, 1:33 PM
Aryan Gupta
Aryan Gupta - avatar