Java shape class not passing | Sololearn: Learn to code for FREE!


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(; 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());}}

12/16/2020 1:38:25 PM

Gayan Suranga

3 Answers

New Answer


You can compare with this.


My programme is working all test cases passed but not allow it passed status


Avinesh do u have any idea about my matter all test cases passed but programme not mark as pass?