A good answer might be:

The completed program is given below.

Complete Program

Here is the complete program:

import java.io.* ;
class HarmonicSeries
{
  double value( int limit )
  {
    int term=1 ;
    double sum = 0.0;
    
    while ( term <= limit )
    {
      sum += 1.0/term;           // add the next term to sum
      term++ ;                   // increment term
    }

    return sum;
  } 
}

class HarmonicTester
{
  public static void main ( String[] args ) throws IOException
  {
    BufferedReader stdin = new BufferedReader( new InputStreamReader(System.in) );
    HarmonicSeries series = new HarmonicSeries();
    int limit = Integer.parseInt( stdin.readLine() );

    System.out.println("Sum of " + limit + " terms:" + series.value( limit) );
  }
}

QUESTION 13:

With my 244MHz Pentium computer it takes 47 seconds to run the program with the limit set at 100,000,000 (100 million.) Is your computer slower or faster than mine?

Click Here after you have answered the question