Question
Heres a link to the assigment https://www.dropbox.com/s/l1kmck79bhkczik/260Laboratory08SP2018%20%281%29.pdf?dl=0 stackTemplate.cpp #include using namespace std; const int MAXSIZE = 20; class Stack { public: Stack(); bool Empty(); void
Heres a link to the assigment
https://www.dropbox.com/s/l1kmck79bhkczik/260Laboratory08SP2018%20%281%29.pdf?dl=0
stackTemplate.cpp
#include
using namespace std;
const int MAXSIZE = 20;
class Stack {
public:
Stack();
bool Empty();
void Push(int item);
void Pop();
int Top();
void displayStack();
private:
int stk[MAXSIZE];
int top;
};
Stack::Stack() {
top = 0;
}
bool Stack::Empty() {
if (top == 0)
return true;
else
return false;
}
void Stack::Push(int item) {
stk[top] = item;
top++;
}
void Stack::Pop() {
top--;
}
int Stack::Top() {
return stk[top];
}
void Stack::displayStack() {
for (int i = 0; i < top; i++)
cout << stk[i] << " ";
cout << endl << endl << top << endl;
}
StackExercise3Template.cpp
#include
#include
using namespace std;
const int MAXSIZE = 5;
class Stack {
public:
Stack();
bool Empty();
void Push(int item);
void Pop();
int Top();
void displayStack();
private:
int stk[MAXSIZE];
int top;
};
bool isNumber(string, int &);
int calculate(int, int, string);
int main() {
Stack expStack;
string inToken;
int num, oprd1, oprd2, result;
// *** enter your code here - ref to the steps
// *** in the lab sheet.
system("Pause");
return 0;
}
Stack::Stack() {
top = 0;
}
bool Stack::Empty() {
if (top == 0)
return true;
else
return false;
}
void Stack::Push(int item) {
stk[top] = item;
top++;
}
void Stack::Pop() {
top--;
}
int Stack::Top() {
return stk[top];
}
void Stack::displayStack() {
for (int i = 0; i < top; i++)
cout << stk[i] << " ";
cout << endl << endl << top << endl;
}
/* this function will take a string and determine if it is
an integer. The function will return true and store the
integer value to number (a reference parameter). it will
return false otherwise.
*/
bool isNumber(string inStr, int & number){
stringstream ss;
ss << inStr;
number = 0;
ss >> number;
if (ss.good())
return false;
else if (number == 0 && inStr[0] != '0')
return false;
else
return true;
}
/*
This function will use switch statement check the
first charactor in op to see if it is "=".
Then it will calculate and return the result. Assume
there are only 4 operators +, -, *, /
*/
int calculate(int num1, int num2, string op) {
// *** write your code here
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started