Results 1 to 12 of 12

Thread: Java methods

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    zombologist Senior Member doc_bean's Avatar
    Join Date
    Oct 2004
    Location
    Riding Shai-Hulud
    Posts
    5,346

    Default Re: Java methods

    Quote Originally Posted by The_Doctor
    This is my first ever method, is it alright?

    //Area of Squares
    public double Area_of_Squares(double Square_Side_Length, int Further_Number_of_Squares, int Square_Size_Increment, double Square_Area, int Counter)
    {
    System.out.println("Enter square side length");
    Square_Side_Length = data_input.nextDouble();
    System.out.println("Enter further number of squares to be calculated");
    Further_Number_of_Squares = data_input.nextInt();
    System.out.println("Enter size increment");
    Square_Size_Increment = data_input.nextInt();

    for(Counter=1; Counter==Further_Number_of_Squares; Counter++)
    {
    Square_Area = Square_Side_Length*Square_Side_Length;
    System.out.printf("Area of Square is f%" , Square_Area);
    Square_Side_Length = Square_Side_Length + Square_Size_Increment;
    }
    return 1;
    }

    Also, how do I call this method.
    just type a=Area_of_Squares(ss,fn,ss,sa,c) with proper numbers (or variabels) as arguments, that should do the trick iirc.

    EDIT: in your for command, shouldn't you use <= instead of == ? It's the continue condition, not ending condition you should use iirc
    EDIT2: why do you return 1 instead of the actual area ?
    Last edited by doc_bean; 03-14-2007 at 17:34.
    Yes, Iraq is peaceful. Go to sleep now. - Adrian II

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO