Include Include Using Namespace Std Class Counter Private Int Mcount Counter Value Int Mst Q43858142
#include
#include
using namespace std;
class Counter {
private:
int m_count; // countervalue
int m_stepSize;
public:
Counter() { m_count = 0;m_stepSize = 1; }
Counter(int count, intstepSize);
int getCount();
void setCounter(int count,int step);
void getData(int& count,int& stepSize);
void incrementCount(); //increment by 1
void incrementCount(intstep);
int getMaxCountValue(intthreshold, int step);
static intgetTotalCount(Counter* ptr, int numCounter);
};
int main() {
Counter c1(1, 2);
int ctr, ss;
c1.getData(ctr, ss);
cout << “n The c1counter value =” << ctr;
cout << “n The c1counter step size :” << ss;
cout << endl;
c1.incrementCount();
cout << “n Updated c1count value = ” << c1.getCount();
c1.incrementCount(10);
cout << “n Updated c1count value = ” << c1.getCount();
cout << endl <<endl;
cout <<” f(k)= 10 + k*5 , find maximum value of f(k) such thatf(k) < 49 “;
Counter c2;
c2.setCounter(10, 5);
int maxV = 49;
cout << “n Maximum c2count value f(k) below ” << maxV << “= ” <<c2.getMaxCountValue(49, 5);
Counter cArray[3];
cArray[0] = Counter(1,1);
cArray[1] = Counter(5,5);
cArray[2] = Counter(10,1);
cout << “nn Totalcount in cArray = ” << Counter::getTotalCount(cArray, 3);
getchar();
return 0;
}

Expected output The c1 counter value =1 The c1 counter step size : 2 Increment count by 2 Updated c1 count value = 3 Increment count by 10 Updated c1 count value = 13 f(k)= 10 + k*5 , find maximum value of f(k) such that f(k) < 49 Increment count by 5 Increment count by 5 Increment count by 5 Increment count by 5 Increment count by 5 Increment count by 5 Increment count by 5 Constraint satisfied at k = 7 Maximum c2 count value f(k) be low 49= 45 Total count in cArray = 16 Figure Q1.2 Implement all the member functions in the Counter class so that the output in the main() function is similar to Figure Q1.2 Note: The name of the variable represent the information it stores No Member function Remark 1 Counter(int count, int sterSize); // Initialize the member variable muscount and 1 mark Mestepsize, based on input argument of the constructor 2 int getCount(); // 1 mark Get and return the member variable Wcount void set counter(int count, int step); Set the member variable count, and stepsize // 1 mark based on the input argument of the function void getDatalint& count, int& Retrieve the member variable M..count and sterSize); //1 mark Mestepsize by using passing by reference 5 Increment m.count by 1 Increment count by step void increment Count(); // 1 mark void increment count(int step); // 1 mark int getMaxcountValue(int threshold, int step); // 2 marks Find the maximum value of count that is below threshold when multiple increment of step is applied Assume count = f(k) = initial value + step*k Find maximum of f(k) such that f(k)< threshold Return the maximum value and display k that satisfy the constraint above. The function must work for different value of threshold and step Sum up the count value for all Counter objects represented by ptr. Return the sum. static int getTetatcount (Counter* ptre int numCounter) // 2 marks Show transcribed image text Expected output The c1 counter value =1 The c1 counter step size : 2 Increment count by 2 Updated c1 count value = 3 Increment count by 10 Updated c1 count value = 13 f(k)= 10 + k*5 , find maximum value of f(k) such that f(k)
Expert Answer
Answer to #include #include using namespace std; class Counter { private: int m_count; // counter value int m_stepSize; public: Co…
OR