create a stack class to implement a rpn calculator that stores integers. output
ID: 3635121 • Letter: C
Question
create a stack class to implement a rpn calculator that stores integers. output a message if there are not two operands on the stack.example of rpn calc
if + is input pop last two and add push sum on stack
if - is input pop val1 pop val2, val2-val1 push diff on stack
if * is input pop last 2 and push product on stack
if / is input pop val1 pop val2, val2/val1 push answer on stack
if E stop, print out top of stack and exit
below is what i have so far
#include<iostream>
#include<stack>
#include<cstddef>
using namespace std;
struct Stack
{int data;
Stack*link;
};typedef Stack* StackPtr;
class Stackss
{
public:
Stackss();//empty stack
Stackss(const Stackss& a_stack);//constructor
~Stackss();//destroy stack return memory to freestore
void push(float );//add to stack
int pop ();// from the stack
bool empty();// false if stack isnt empty
float option( float value1, float value2, char *function[0]);
char function;
switch ( function [0])
{
case'+':
total = value1 + value2;
break;
case '-':
total = value2 - value1;
break;
case '*':
total = value1 * value2;
break;
case '/':
total = value2 / value1;
break;
case 'E':
cout << "Stop inputting values" << endl;
exit(1);
push(total);
};
private:
StackPtr top;
};
void main ()
{
return;}