Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

stack.h

#ifndef STACK_H
#define STACK_H
#define MAX 100
//class stack
class stack
{
int top;
public:
//function declarations
stack();
char array[MAX];
void push(char x);
char pop();
char getTop();
bool isEmpty();
bool isFull();

};
#endif

stack.cpp

#include "stack.h"

#include <iostream>

using namespace std;
//default constructor initializes top as -1
stack::stack() {
top = -1;
}
//returns the top element of stack
char stack::getTop() {
return array[top];
}
//thuis method adds an element in array by adding the top by 1
void stack::push(char x) {
if (isFull()) {
cout << "Stack Overflow";

} else {
array[++top] = x;

}

}
//this method returns the top element of stack and decrement the top by 1
char stack::pop() {
if (isEmpty()) {
cout << "\nStack is Empty";
return 0;
} else {
char x = array[top];
top--;
return x;
}
}
//this methd checks the stack is empty or not
bool stack::isEmpty() {
return (top < 0);
}
//this method checks the stack is full or not
bool stack::isFull() {
return (top >= MAX);
}

Create the postfix.cpp file the converts an infix expression into a postfix expression. You must use the stack.h and stack.cpp implemented in Part 1. The program must allow the user inputs, and the inputs should not include any alphabets. You need to handle (','), +, 5, 7, *** and % operators. "N? will not be considered in this program. Also, please consider only one digit numbers. The following links can be helpful for the conversions from string to integer or double types. Create a menu loop in your application asking if the user wants to enter another expression. When doing your error handling and showing this message "I cannot create a postfix form - Error". If you can replace "Error" with the reason for the error e.g. "I cannot create a postfix form - Non numeric values not allowed" for a + b * c.

This program also needs to evaluate the infix expression and display the result after the postfix.

EX.

Enter an infix expression: 2 + 3 * 4

The postfix form is 2 3 4 * +

The result is 14

This program needs to be developed using c++ language

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY