w is 25.0 x is 1.0
Our goal is to write a program that computes the following sum:
sum = 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6
(This may look like a pointless thing to do, but you will see such sums in calculus, where they are called harmonic series.) Here is a skeleton of the program:
A few notes on the program:
HarmonicSeries
describes an object that can compute the sum we want.value()
of that object will do the computation.HarmonicSeries
constructor exists automatically, even though the
program doesn't explicitly describe one.HarmonicTester
creates a HarmonicSeries
object, then
uses value()
to calculate the sum, then prints it out.Fill in the two blanks to complete the program. (This situation is very common in programming and it would be very good practice for you to think about this question before going on.)