Question: Please write the program in C++ language 4. Write the necessary member functions to create a counter class which counts from zero to a maximum

 Please write the program in C++ language 4. Write the necessarymember functions to create a counter class which counts from zero to

Please write the program in C++ language

4. Write the necessary member functions to create a counter class which counts from zero to a maximum then back down to zero as in the program updown.cpp. Do not modify the main program. You must supply the source code for the methods. File: updown.cpp Program to illustrate classes with a simple counter which counts to a maximum value and then counts back dovn to zero at which point the process repeats Programmer: your name Date: #include #include using namespace std; // this class represents a counter which counts up from 0 to max // then back down to 0 and the process repeats class updown t rivate: // count cycles betueen 0 and max int max int direction / 1 means count up, 0 means count down int value // this is the value stored in the counter public: updown (int top) I/ constructor max is set to top void count (void); I/ increment or decrement value depending on direction int getvalue(void) const; // return value int main void) ofstream fout ("updown.txt"); // prepare the output file updown c(7) // declare a counter object c // the constructor updown (7) is called which sets // c.value 0, c.direction 1 and c.max7/ int i; for (i-1; i

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!