public abstract class Shapes{ public abstract double area(); public abstract double perimeter (); } public class Rectangle extends Shapes{ double width; double length; public Rectangle(){ this(1,1); } public Rectangle(double width, double length){ this.width = width; this.length = length; } public double area(){ return width * length; } public double perimeter(){ return 2*(width + length); } } public class Triangle extends Shapes{ double a; double b; double c; public Triangle(){ this(1,1,1); } public Triangle (double a, double b, double c){ this.a = a; this.b = b; this.c = c; } public double area(){ double s = (a+b+c)/2; return Math.sqrt(s*(s-a)*(s-b)*(s-c)); } public double perimeter(){ return a+ b + c; } } public class Test{ public static void main(String[]args){ double width = 10; double length = 25; Shapes Rectangle = new Rectangle (width, length); System.out.println("The area of the rectangle is: " + Rectangle.area()); System.out.println("The perimeter of the rectangle is: " + Rectangle.perimeter()); } } What I have tried: I'm a little confused as to why the errors below are appearing. Main.java:1: error: class Shapes is public, should be declared in a file named Shapes.java public abstract class Shapes{ ^ Main.java:5: error: class Rectangle is public, should be declared in a file named Rectangle.java public class Rectangle extends Shapes{ ^ Main.java:23: error: class Triangle is public, should be declared in a file named Triangle.java public class Triangle extends Shapes{ ^ Main.java:44: error: class Test is public, should be declared in a file named Test.java public class Test{ ^ 4 errors Would you be able to help me understand what I did wrong and how I can correct it?
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)