Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ class that is derived from the Progression class to produce a progre

ID: 3882978 • Letter: W

Question

Write a C++ class that is derived from the Progression class to produce a progression where each value is the absolute value of the difference between the previous two values. You should include a default constructor that starts with 2 and 200 as the first two values and a parametric constructor that starts with a specified pair of numbers as the first two values.

Prorgression Class

int main()

{

Progression* prog; // test ArithProgression

cout << "Arithmetic progression with default increment: ";

prog = new ArithProgression();

prog>printProgression(10);

cout << "Arithmetic progression with increment 5: ";

prog = new ArithProgression(5);

prog>printProgression(10); // test GeomProgression

cout << "Geometric progression with default base: ";

prog = new GeomProgression();

prog>printProgression(10);

cout << "Geometric progression with base 3: ";

prog = new GeomProgression(3);

prog>printProgression(10); // test FibonacciProgression

cout << "Fibonacci progression with default start values: ";

prog = new FibonacciProgression();

prog>printProgression(10);

cout << "Fibonacci progression with start values 4 and 6: ";

prog = new FibonacciProgression(4, 6);

prog>printProgression(10);

return EXIT SUCCESS; // successful execution

}

Explanation / Answer

class DerivedProrgression:Progression

{

int first;

int second;

public:

DerivedProrgression()

{

first=2;

second=200;

}

DerivedProgression(int f,int s)

{

first=f;

second=s;

}

void printProgression(int count)

{

int i,f=first,s=second,next;

for(i=0;i<8;i++)

{

next=abs(f-s);

cout<<next;

f=s;

s=next;

}

}

};

int main()

{

Progression* prog; // test ArithProgression

cout << "Derived progression with default start values(2 and 200): ";

prog = new DerivedProgression();

prog->printProgression(10);

cout << "Derived progression with start values 10 and 20: ";

prog = new DerivedProgression(4, 6);

prog->printProgression(10);

return EXIT SUCCESS; // successful execution

}

Include the class and the statements in main() in your program and compile and run it. Let me know through comment if you face any problem. Just for future's sake if you post a question in which you want any help and you've some done it, then also attach the part you've done. I'll be happy to help if you face any problem.

Thank you.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote