Hey, I need to allow the user to select a shape, out of three shapes, Square, Circle or Triangle.

They then input a Length value for that shape, which is then used to calculate the boundary length and area of the chosen shape. Which is then displayed, and the program returns to the shape selection screen.

This needs to be done with 4 classes, 3 of which hold the calculations for the 3 different shapes, and the last class, the super class(if that's what it is, not too sure).

Here's what i have so far:

--------------MyShape.java-------

package calculations; import java.io.*; import java.util.Scanner; public class MyShape { double boundaryLength; double area; double length; public static void main(String[] args) { int number ; double length; Scanner scan = new Scanner(System.in); System.out.println("Select a shape:"); System.out.println("1. Square"); System.out.println("2. Circle"); System.out.println("3. Triangle"); number = scan.nextInt() ; if (number == 1)//this will use the Square class { System.out.println("Enter the length: ") ; length = scan.nextDouble(); } else if (number == 2)//this will use the Circle class { System.out.println("Enter the length: ") ; length = scan.nextDouble(); } else if (number == 3)//this will use the Triangle class { System.out.println("Enter the length: ") ; length = scan.nextDouble(); } System.out.println("Boundary Length = " +boundaryLength); System.out.println("Area = " +area); } }

--------------Square.java-------------

package calculations; class Square { private double boundaryLength = length + length + length + length; private double area = length * length; }

--------------Circle.java-------------

package calculations; public class Circle { private double boundaryLength = 2 * length * Math.PI; private double area = length * length * Math.PI; }

--------------Triangle.java-----------

package calculations; public class Triangle { private double boundaryLength = (length + length) + Math.sqrt(2*length*length); private double area = 0.5 * length * length; }

I know this is probably completely wrong, but if you could help me in the right direction, it would be great. I'm not looking for a completed program, just help in how i can get this working.

Thanks, Jason.