Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago