Java shape class not passing | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Java shape class not passing

Dear all, I have done the java test tutorial it is passing g the test case but problem is this session not completed is there any issues of my code import java.util.Scanner; abstract class Shape { int width; public void setValue(int width) {this.width = width; } public int getWidth() { return width; } abstract double area(); } //your code goes here class Circle extends Shape{ public double area (){ return getWidth() * getWidth()*Math.PI; } } class Square extends Shape{ public double area(){ return getWidth() * getWidth(); } } public class Program { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); Shape sp; Square a = new Square (); sp =a; sp.setValue(x); System.out.println((int)sp.area()); Circle b = new Circle(); sp =b; sp.setValue(y); System.out.println(sp.area());}}

16th Dec 2020, 1:38 PM
Gayan Suranga
Gayan Suranga - avatar
3 Answers
0
My programme is working all test cases passed but not allow it passed status
18th Dec 2020, 3:17 PM
Gayan Suranga
Gayan Suranga - avatar
0
Avinesh do u have any idea about my matter all test cases passed but programme not mark as pass?
20th Dec 2020, 1:29 PM
Gayan Suranga
Gayan Suranga - avatar