Hey my program is all set up to calculate but for some reason when i type in the modulus (%)the result is 000 but the rest of the operations work? i could really use some help the program is due tomorrow. I also need to add a bool variable to indicate whether an error has occurred. If the error is true then don’t display the normal output, but instead display an error message. You can also display the error directly from the switch() statement. Thanks!
// Program to use RPN
//
// Author:
//
// Date: 3/4/20
//
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
// precision is done inside printf.
int main()
{
double num1, num2; // 2 variables
char op; // operator
double dResult; // result of doubles
int iResult; // result of intergers
ah, a coder after my own heart. When I saw the winx calc mess I wrote one of these too.
I found that a stack for the inputs is very useful, but I am used to a HP11C and sort of expect that functionality.
I also just process what they put in, using that idea, rather than prompt for operators, input like
3
4
5
*
+
= 23
yours isnt tapping the power of RPN because it forces the user to put things into it in a certain order. Its close... just detect if the input is a keyword/operator/etc or a numeric value.