0

Hello my question is fairly simple though I can't seem to find the solution. I'm writing a program that basically calculates the area of different shapes. I am making a seperate method per shape to do the calculations but in my main method I need to call the method according to what shape it is. I have the program ask which shape, how do i make it call the method the user inputs for?
I have the shapes listed like this :

        int 1 = triangle;
        int 2 = square;
        int 3 = rectangle;
        int 4 = trapezoid;
        int 5 = pentagon;
        int 6 = hexagon;
        int 7 = octagon;
        int 8 = circle;

        System.out.println("Enter the number of the shape you are calculating the are of.");
        System.out.println("1. Triangle");
        System.out.println("2. Square");
        System.out.println("3. Rectangle");
        System.out.println("4. Trapezoid");
        System.out.println("5. Pentagon");
        System.out.println("6. Hexagon");
        System.out.println("7. Octagon");
        System.out.println("8. Circle");
        keyboard.nextInt();

I have the methods written out, below in the program. I just need to know how to call the method. Any help would be much appreciated.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by JamesCherrill
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.