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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

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