Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22
  1. #21
    mnki23 is offline Member
    Join Date
    Nov 2009
    Rep Power



    So i was playing around with the code and here is another solution that works...

    public class Assignment4 {
    /* main method */
    public static void main(String[] args) {
    double mi=0.0; //used to catch the return value from method m(i)
    //Print the header

    //Print the table
    for (int i = 1; i <= 20; i++) {
    mi=recess(i); //Fill in blank here. Call the method
    System.out.println(i+"\t\t"+ mi);
    } //end for

    } //end main

    /* define non-void method m(i) here */

    public static double recess(int capture){
    double sum=0.0;
    for(double i=1;i<=capture;i++)
    return sum;


    //end class

    Again thanks so much!!

  2. #22
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power


    That is just stupid: first you calculate 1/2, then you calculate 1/2+2/3 and so on and so on and you forget about all the results except the last one, the one that you want. Better use your previous method. Stick a System.out.println( ... ) statement inside the body of the loop in your method on you'll see ...

    kind regards,


Page 2 of 2 FirstFirst 12

Similar Threads

  1. calling method from main method
    By bob_bee in forum New To Java
    Replies: 4
    Last Post: 10-02-2009, 05:30 PM
  2. Need help calling from a different method
    By Mayur in forum New To Java
    Replies: 6
    Last Post: 03-08-2009, 10:27 PM
  3. Replies: 29
    Last Post: 09-25-2008, 07:55 PM
  4. method calling?
    By frejon26 in forum New To Java
    Replies: 4
    Last Post: 01-25-2008, 04:38 AM
  5. Help with Calling a method
    By Albert in forum New To Java
    Replies: 3
    Last Post: 07-10-2007, 03:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts