Question: CAN SOMEONE PLEASE TELL MY WHY MY CODE IS RECIEVING ERRORS WITH THE FOLLOWING LINES OF CODE **** else if(!isdigit(token[0])&&token!=+&&token!=-&&token!=*&&token!-/){ **** AND. **** if(result=CLX){ stack.pop();

 CAN SOMEONE PLEASE TELL MY WHY MY CODE IS RECIEVING ERRORS

WITH THE FOLLOWING LINES OF CODE **** else if(!isdigit(token[0])&&token!="+"&&token!="-"&&token!="*"&&token!-"/"){ **** AND. ****

if(result="CLX"){ stack.pop(); } ****** #include #include #include #include #include #include using namespace

std; class HPStack{ public: double x,y,z,t,temp,temp2,mem; void push (double a){ temp=t; t=z;

CAN SOMEONE PLEASE TELL MY WHY MY CODE IS RECIEVING ERRORS WITH THE FOLLOWING LINES OF CODE

**** else if(!isdigit(token[0])&&token!="+"&&token!="-"&&token!="*"&&token!-"/"){ ****

AND. **** if(result="CLX"){ stack.pop(); } ******

#include #include #include #include #include #include

using namespace std;

class HPStack{ public: double x,y,z,t,temp,temp2,mem; void push (double a){ temp=t; t=z; z=y; y=x; x=a; if(a==-64) x=temp2; } double pop(){ temp2=x; x=y; y=z; z=t; t=temp; return temp2; }

double peek(){ return x; } void CLR(){ x=0; y=0; z=0; t=0; } void SWAP(){ temp=x; x=y; y=temp; } void ROLL(){ temp=t; t=x; x=y; y=z; z=temp; } void ENTER(){ t=z; z=y; y=x; temp=2;

} };

int main(int argc, char** argv){ HPStack stack; string line; while(getline(cin, line)){ stringstream expression(line); string token; while(expression >> token){ if(isdigit(token[0])){ stack.push(atof(token.data())); } else if(!isdigit(token[0])&&token!="+"&&token!="-"&&token!="*"&&token!-"/"){ string result=""; for(int i=0; i

Background ENTER The HP-35 was the first scientific hand-held calculator, released in 1972 and an immediate success with engineers and scientists. Amongst other features, it used an unusual way of entering numbers, called RPN. RPN (reverse Polish notation, named for Polish mathematician Jan Lukasiewicz) allows complex calculations to be entered without the use of parentheses. The key difference is that operators are entered afier the operands, rather than between them The HP-35 implemented RPN using a stack of 4 registers, referred to as X, Y, Z, and T. The value in the X register is the one shown on the calculator's LED display; the other registers are used for temporary values during calculations. New values are entered into the X register, with goes into Z, the old value of Z goes into T, and the old value of T is lost. Single-operand functions (such as square root) use and replace the value in the X register; other registers are unchanged. Functions that operate on 2 values (such as the arithmetic operators) use the values in Y and X, with the result going back into X. Values in the Z and T registers are "dropped" down the stack, with Z overwriting the old Y and T overwriting the old Z. The value of T is preserved, providing a simple way to do calculations with repeated values This scheme allows calculations to be entered without using parentheses. For example, you could compute the compound expression (5 + 4)/(3 - 2) like this: 5 ENTER 4 + 3 ENTER 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!