+ 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.
6 Antworten
0
Please post what you have tried
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();
}
}
0
It's working fine. What's the problem?
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.
0
Can you tell me the name of that module?
0
Ya, The name of the module is "More on Classes" and the project name is "Shapes".