Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ PROGRAMMING please make sure program compiles and runs for 5 stars :-) FILL IN THIS CODE: #include #include using namespace std; class Stack {
C++ PROGRAMMING please make sure program compiles and runs for 5 stars :-)
FILL IN THIS CODE: #include#include using namespace std; class Stack { public: Stack() { Stack(10); } Stack(int capacity) : cap(capacity - 1), top(0) { data = new char[capacity]; } ~Stack() { delete data; } void push(char value); char pop(); bool isEmpty(); private: int top, cap; char *data; }; void Stack::push(char value) { if (top == cap) { /* Full stack */ return; } data[top++] = value; } char Stack::pop() { if (top == 0) { /* Empty stack */ return '\0'; } return data[--top]; } bool Stack::isEmpty() { return top == 0; } int main(void) { cout CSC 2111 optional lab 2 objectives: Implement and utilize a stack abstract data type Question 1: Accompanying this question is a skeleton of a program that defines a Stack class, as well as a main function to read an algebraic expression from the user. Complete the main program and determine if the user has provided an expression with a balanced set of parenthesis. The mechanism for checking if the parenthesis are balanced must make use of a stack. Example outputs: Enter an expression 1 3 Balanced Parenthesis Press any key to continue Enter an expression 1 (3 5 7 Mismatched Parenthesis Press any key to continue Enter an expression 3 7) Balanced Parenthesis Press any key to continue Enter an expression 3 7 4 Mismatched Parenthesis Press any key to continue
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