Shapes lab for Java course
The code doesn't work. What do I need to change? ------------------ import java.util.Scanner; import java.math.BigDecimal; abstract class Shapes { BigDecimal width; abstract void area(); } //your code goes here class Square extends Shapes{ BigDecimal width; public Square(BigDecimal x) { this.width = x; } public void area(){ System.out.println(this.width.multiply(this.width)); } } class Circle extends Shapes{ BigDecimal width; public Circle(BigDecimal y){ this.width = y; } public void area(){ System.out.println(this.width.multiply(this.width.multiply(new BigDecimal(Math.PI))).doubleValue()); } } public class Program { public static void main(String[ ] args) throws Exception { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); if (x <= 0 && x <= Integer.MAX_VALUE) { throw new Exception(); } else { BigDecimal x_float = new BigDecimal(x); Square a = new Square(x_float); a.area(); } if (y <= 0 && y <= Integer.MAX_VALUE) { throw new Exception(); } else { BigDecimal y_float = new BigDecimal(y); Circle b = new Circle(y_float); b.area(); } if (x <= 0 && y <= 0) { throw new Exception(); } } }