Question: 1+ Objective: Learn how to -- use the counted for loops -- handle errors with a while loop Problem: In mathematics, the harmonic series is

 1+ Objective: Learn how to -- use the counted for loops

1+ Objective: Learn how to -- use the counted for loops -- handle errors with a while loop Problem: In mathematics, the harmonic series is the divergent infinite series: 1 1 1 1 1 + 3 + + 2 + 4 5 Its name derives from the concept of overtones, or harmonies in music: the wavelengths of the overtones of a vibrating string are 1/2, 1/3, 1/4, etc., of the string's fundamental wavelength. Write a C++ program that uses a for loop to calculate the harmonic sum of the first num (positive integer) terms of the series. Include in the program, an error check (while loop) to ensure that a positive integer is entered for num. Also, output the harmonic sum as a fixed point with two places after the decimal. You should include an outer for loop to test the required number of cases. For example, if num = 3 calculate: n=1 For example, if num = 5 calculate: Suggested screen design: How many Harmonic Sumo to calculato? 3 Enter an integer: 1 Harmonic Sun: 1.00 Entor an integer: -3 Invalid Input. You must enter a positive integer Please enter another integer : -5 Invalid Input. You must enter a positive integer, Please enter another integer: 3 Harmonic Sum: 1.83 Enter an integer: 5 Harmonic Sum: 2.28 Press any key to continue for Loop (For Each Test Case) Input num while Loop (Error Check) for Loop to calculate Harmonic Sum Output Harmonic Sum (For Each Test Case)

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 Databases Questions!