Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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

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_2

Step: 3

blur-text-image_3

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

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

How does the concept of hegemony relate to culture?

Answered: 1 week ago