1. Evaluate a postfix expression
0. Exit
Enter the number for the option: 1
Evaluate a postfix expression
Enter the expression: 34*873-//4+
The Postfix Expression entered is: 34*873-//4+ and the value of the Postfix Expression is: 3.95833 but the answer must be 10, what is wrong with the calculations
#include"stack.h"
#include<string>
#include<iostream>
using namespace std;
int main()
{
int i, choice;
string postfixExp;
char token;
float value, value1, value2;
//Stack <char> stack_one;
Stack <float> stack_one;
while (choice != 0)
{
cout << "1. Evaluate a postfix expression" << endl;
cout << "0. Exit " << endl;
cout << "Enter the number for the option: ";
cin >> choice;
switch(choice)
{
case 1: cout << "Evaluate a postfix expression\n";
cout << "Enter the expression: ";
cin >> postfixExp;
i = 0;
token = postfixExp[i];
switch(token)
{
case '+': value = value1 + value2;
break;
case '-': value = value1 - value2;
break;
case '*': value = value1*value2;
break;
case '/': value = value1/value2;
break;
}
stack_one.push(value);
}
i++;
token = postfixExp[i];
}
stack_one.isEmpty();
value = stack_one.peek(value);
stack_one.pop(value);
cout <<"\nThe Postfix Expression entered is: " << postfixExp <<" and the value of the Postfix Expression is: "<< value << endl;
break;