Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Java program namedHarmonicSeriesthat sums the terms of the Harmonic series:1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6... Your program should accept

The Java programnamedHarmonicSeriesthat sums the terms of the Harmonic series:1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6...

Your program should accept from the console a double number representing a limit, determine the minimum number of terms which when summed will exceed that limit, and report the actual sum of those terms.

For example, a user input to the console of 1.5 should result in this console output:

Actual sum = 1.83333

Number of terms required: 3

In other words, a minimum of 3 terms of the Harmonic series are required to exceed the sum of 1.5, and the sum of those 3 terms is 1.83333 (rounded).

You may useprintfto round your sum to the nearest 5thdecimal place.Your sum must be rounded, not truncated.

Other test cases, not available to you, will also be tested.Assume that the target sum will always be in the range 1 to 10.(In fact, be careful not to test for sums much larger than 10 because your program might take many precious seconds to execute.)

Be sure to match the format of the example EXACTLY.There are two lines of output with no blank lines and no trailing spaces.If the number or terms exceeds1,000, output with no commas, e.g. 1000.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions