A good answer might be:

The completed program is given below


Completed Program

Here is the completed program:

class HarmonicSeries
{
  double value()
  {
    int term=1, lastTerm = 6;
    double sum = 0.0;
    
    while ( term <= lastTerm )
    {
      sum += 1.0/term;           // add the next term to sum
      term++ ;                   // increment term
    }

    return sum;
  } 
}

class HarmonicTester
{
  public static void main ( String[] args )
  {
    HarmonicSeries series = new HarmonicSeries();

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

You might wish to copy this program to your editor and run it. If you do, you will see something like:

C:\users>java HarmonicTester

Sum of 6 terms:2.4499999999999997

QUESTION 11:

How might this program be improved? Click here for a