Question: Separate the program into three4 files: the class interface, the class implementation, and the driver. ------------------------------------------------------------------------------------ //Program: Money counter #include #include #include using namespace std;

Separate the program into three4 files: the class interface, the class implementation, and the driver.

------------------------------------------------------------------------------------ //Program: Money counter

#include #include #include using namespace std;

class Counter{ public: void incr1 (); // increment by 1 void incr10 (); // increment by 10s void incr100 (); // increment by 100s void incr1000 (); // increment by 1000s void reset (); // reset the calculator int CounterValue (); bool over; int value; Counter (int max); private: int num; int max; };

// set letters parameters for the count bool letters(char valueEntered) { if (valueEntered == 'c') return true; if (valueEntered == 'm') return true; if (valueEntered == 'd') return true; if (valueEntered == 't') return true; if (valueEntered == 'r') return true; return false; } Counter::Counter(int letterEntered) { num = 0; max = letterEntered; over =false; return; }

// all the increments void Counter::incr1() { num +=1; } void Counter::incr10() { num += 10; } void Counter::incr100() { num += 100; } void Counter::incr1000() { num += 1000; }

// reset function to reset to zero void Counter::reset() { num = 0*num; } int Counter::CounterValue() { return num; }

int main() { char valueEntered; Counter counter(1000000); // give the user a list of available options cout << "Select one of the following: (C) for cents (M) for dimes (D) for dollars (T) for hundreds (R) to reset" << endl; cout << "Enter your selection: "; cin >> valueEntered; // calculate the total until the user requests to reset back to zero by clicking R // c to add cents, m to add in the dime section, d to add dollars, t to add thousands, r to reset to zero while (letters(valueEntered)) { switch (valueEntered){ {case 'c': if (valueEntered == 'c') counter.incr1(); cout << "You spent this much: $" << counter.CounterValue() << endl; break;} {case 'm': if (valueEntered == 'm') counter.incr10(); cout << "You spent this much: $" << counter.CounterValue() << endl; break;} {case 'd': if (valueEntered == 'd') counter.incr100(); cout << "You spent this much: $" << counter.CounterValue() << endl; break;} {case 't': if (valueEntered == 't') counter.incr1000(); cout << "You spent this much: $" << counter.CounterValue() << endl; break;} {case 'r': if (valueEntered == 'r'){ counter.reset(); cout << "Reset Successful" << endl; break;} } } cout << "Enter a selection: "; cin >> valueEntered; } cout << endl; cout << "You spent: $"; cout << counter.CounterValue() << endl; system ("pause"); // program pauses and reruns and show the total }

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!