Question: Your method should accept a real number as a parameter representing a maximum limit, and should repeatedly add terms of the sequence until the overall

Your method should accept a real number as a parameter representing a maximum limit, and should repeatedly add terms of the sequence until the overall sum of terms meets or exceeds the maximum limit that was passed. For example, if your method is passed the value of 2.0, you should add terms of the sequence until the sum of all those terms is at least 2.0. The method should both return the final sum, in addition to printing out the fractions used and the final sum. 1/1 + 1/2 + 1/3 + 1/4 = 2.083333333333333 (Despite the fact that the terms keep getting smaller, the sequence can actually produce an arbitrarily large sum if enough terms are added.) If your method is passed any value less than 1.0, the value -1.0 should be returned. Other sample calls: sequenceSum(2.0); a. Prints : 1/1 + 1/2 + 1/3 + 1/4 = 2.083333333333333 b. 2.083333333333333 is returned sequenceSum(2.5); a. Prints : 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 = 2.5928571428571425 b. 2.5928571428571425 is returned sequenceSum(4.0); a. Prints : 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 + 1/8 + 1/9 + 1/10 + 1/11 + 1/12 + 1/13 + 1/14 + 1/15 + 1/16 + 1/17 + 1/18 + 1/19 + 1/20 + 1/21 + 1/22 + 1/23 + 1/24 + 1/25 + 1/26 + 1/27 + 1/28 + 1/29 + 1/30 + 1/31 = 4.02724519543652 b. 4.02724519543652 is returned sequenceSum(0.99); a. Prints : Error: must be larger than one. b. -1.0 is returned Remember that your code will both PRINT and RETURN. So keep that in mind

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!