Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Programming exercise. Write a C++ class HarmProgression derived from the ab- stract Progression class to produce a harmonic progression, which is to say, a

image text in transcribedimage text in transcribed

3. Programming exercise. Write a C++ class HarmProgression derived from the ab- stract Progression class to produce a harmonic progression, which is to say, a pro- gression where the reciprocals of the values form an arithmetic progression. Just like with an arithmetic progression, it is defined by its first value l and its increment d (20 pts.) and its n-th element is given by the formula at(n-1)od Details and suggestions: The source code for the Progression class is available in lines 645 to 661 of this file: https://www.overleaf.com/read/pmjttghgmnr; be sure to remove any LaTeX code. Modify the abstract class to allow floating-point numbers Print the numbers one per line, rounded to 5 decimals; do not change them internally. The definition of next Value() should remain very short (2-3 lines at most) le a default constructor that starts with 1 as the firs lso include a parametric constructor that takes any first value and increment Bonus: get the class to throw a ZeroDivide exception with the message "Divide by zero in Module HarmProgression. if a division by 0 occurs instead of failing. Test cases (you must make sure your program works on these): prog new HarmProgression(); prog -> printProgression(5); prints out 0.5 0.33333 0.25 0.2 prog new HarmProgression(1,0); prog -pintProgression(5); prints out five 1's. prog = new HarmProgression(0.5, 1); prog > printProgression(5): prints out 0.5 0.33333

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

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions