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

#include<iostream> class Progression { // a generic progression public:Progressi

ID: 3648771 • Letter: #

Question

#include<iostream>

class Progression
{
// a generic progression

public:Progression(long f = 0)// constructor: ?rst(f), cur(f)
{ }

Virtual Progression()
{ };// destructor

Void printProgression(int n);// print the first n values
protected : virtual long firstValue();// reset
virtual long nextValue();// advance
protected:long first;// ?rst value
long cur;// current value
};

Void Progression::printProgression(int n)
{ // print n values
cout<<firstValue();// print the ?rst
for(int i = 2; i<= n; i++)// print 2 through n
cout<<' '<<nextValue();cout<<endl;
}



class FibonacciProgression :public Progression
{
// Fibonacci progression
public :FibonacciProgression(long f = 0,long s = 1);// constructor
protected :virtual long frstValue();// reset
virtual long nextValue();// advance
protected:long second;// second value
long prev;// previous value

};



FibonacciProgression::FibonacciProgression(long f,long s): Progression(f), second(s), prev(second-first){ }
long FibonacciProgression::firstValue(){
// reset cur = ?rst;
prev = second-first;// create ?ctitious prev
return cur;
}
long FibonacciProgression::nextValue()
{
// advance
Long temp = prev;
prev = cur;
cur += temp;
return cur;
}
}
}

Explanation / Answer

#include using namespace std; long fib_num ( long ); int main() { long num = 0; long sequence = 0; cout > num; if ( num < 0) { cout