Question: Need Help with To - Do Sections for Data Code #include using namespace std; / / Specification for the IntStack class class IntStack { private:

Need Help with To-Do Sections for Data Code
#include
using namespace std;
// Specification for the IntStack class
class IntStack
{
private:
int *stackArray; // Pointer to the stack array
int stackSize; // The stack size
int top; // Indicates the top of the stack
public:
// Constructor
IntStack(int);
// Copy constructor
IntStack(const IntStack &);
// Destructor
~IntStack();
// Stack operations
void push(int);
void pop(int &);
bool isFull() const;
bool isEmpty() const;
};
// Specification for the MathStack class
class MathStack : public IntStack
{
public:
// Constructor
MathStack(int s) : IntStack(s){}
// MathStack operations
void add();
void sub();
// TO DO 1: Add below the declaration for the multiplication function
// TO DO 2: Add below the declaration for the division function
// TO DO 3: Add below the declaration for the modulus function
};
// The main function section below demonstrates usage of the MathStack class.
int main()
{
int catchVar; // To hold values popped off the stack
const int STACK_SIZE =2; // The minimum number of integers that the
// stack can hold
// Note that this usage portion of the MathStack class can be enhanced to
// be user interactive. However, for this project and ease for the
// evaluation, please simply use the non-interactive form below.
// Create a MathStack object.
MathStack stack(STACK_SIZE);
// Push 3 and 6 onto the stack.
cout << "Pushing 3
";
stack.push(3);
cout << "Pushing 6
";
stack.push(6);
// Add the two values.
stack.add();
// Pop the sum off the stack and display it.
cout << "The sum is ";
stack.pop(catchVar);
cout << catchVar << endl << endl;
// Push 7 and 10 onto the stack
cout << "Pushing 7
";
stack.push(7);
cout << "Pushing 10
";
stack.push(10);
// Subtract 7 from 10.
stack.sub();
// Pop the difference off the stack and display it.
cout << "The difference is ";
stack.pop(catchVar);
cout << catchVar << endl;
// TO DO 7: Provide below usage for the multiplication
// TO DO 8: Provide below usage for the division
// TO DO 9: Provide below usage for the modulus
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// DO NOT modify (delete or add) the code below at all.
cout << endl;
time_t dateTime = time(NULL);
string dateValue =(char *)(ctime(&dateTime));
// Display a thankful message, a note, date and time, author's name, and
// copyrights.
cout <<"***************************************************************
";
cout << "Thank you for writing Project 3 on your own. I hope you enjoyed
"
<< "learning.
"
<<"
"
<< "Note:
"
<<" It is absolutely your responsibility to attend classes,
"
<<" ask questions and to review previous concepts covered in
"
<<" other programming courses. Finally, avoid excuses which do
"
<<" do lead you to nowhere, but may set you up for failure.
"
<<" This is my sincere and professional advice with no
"
<<" disrespect. Keep in mind, \"Easy way in, hard way out.\"
"
<<" By Prof. Donathan Matthew, PhD, SCJP
"
<<"
"
<< "Date: "<< dateValue <<"
"
<< "Main Author: Prof. Donathan Matthew, PhD, SCJP
"
<<" All Rights Reserved
"
<<"***************************************************************
";
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// End of DO NOT modify
return 0;
}
// Implementation for the IntStach class
//***********************************************
// Constructor *
// This constructor creates an empty stack. The *
// size parameter is the size of the stack. *
//*****************************************

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 Programming Questions!