A three numbers operation Calculator
<p>The problem is that if the first action the program calculates (depends on the order of operation) is something divided by 0 (e.g 7/0+3, or 3+7/0), it prints the error message but performs the next action.</p>

<p>Example-</p>

<p>Input: 7/0+2 -----> Output: You can't divide by zero.7/0+2=2</p>

<p>What it should do ----> Output: You can't divide by zero.</p>

<p>It happens because I can't get it to skip the next <em>switch</em> action. If you have an idea or know how o fix it please help.
Thank you</p>

<p>P.S
If you know a better way to tackle the Order of Operation problem please help.</p>

<p>Shortened code:
Just enter something like 7+4/0 or 7-4/0</p>

<pre><code>#include"stdafx.h"
using namespace System;
#include&lt;iostream&gt;
using namespace std;
int main()
{
    long double num1, num2, num3, res;
    char action1, action2;
    cin &gt;&gt; num1 &gt;&gt; action1 &gt;&gt; num2 &gt;&gt; action2 &gt;&gt; num3;
    if ((action2 == '*' || action2 == '/') &amp;&amp; (action1 == '-' || action1 == '+'))  //action2 will be preformed before action1 (Order of operation)
    {
        switch (action2)  //I didn't include the options for '+' or '-' because the if statement requires action2 to be '*' or '/'.
        {
        case('/'):
            if(num3==0)
                cout&lt;&lt; "Error, you can't divide by zero";
            else
                res = num2 / num3;
            break;
            default:
                cout &lt;&lt; "Input not recognized";
                break;
            }
            switch (action1)
            {
            case('+'):
                cout &lt;&lt; num1 &lt;&lt; "+" &lt;&lt; num2 &lt;&lt; action2 &lt;&lt; num3 &lt;&lt; "=" &lt;&lt; res + num1;
                break;
            case('-'):
                cout &lt;&lt; num1 &lt;&lt; "-" &lt;&lt; num2 &lt;&lt; action2 &lt;&lt; num3 &lt;&lt; "=" &lt;&lt; res - num1;
                break;
            default:
                cout &lt;&lt; "Input not recognized";
                break;
            }
    }
    cout &lt;&lt; "\n\n";
    system("PAUSE");
    return 0;
}
</code></pre>

<p>Full code:</p>

<pre><code>// Three numbers Calculator
/*Known problems: when the first action is divided by zero the programs prints the error message but runs the next action.
Other than that I think most of the stuff works but I need to check*/
#include "stdafx.h"
using namespace System;
#include&lt;iostream&gt;
using namespace std;
int main()
{
    cout &lt;&lt; "Enter action as # to exit program" &lt;&lt; endl;
    cout &lt;&lt; "Possible actions:+,-,*,/\n" &lt;&lt; endl;
    int a = 1; //loop veriable
    while (a == 1) //loop
    {
        long double num1, num2, num3, res;
        char action1, action2;
        cin &gt;&gt; num1 &gt;&gt; action1 &gt;&gt; num2 &gt;&gt; action2 &gt;&gt; num3;
        if ((action2 == '*' || action2 == '/') &amp;&amp; (action1 == '-' || action1 == '+'))  //action2 will be preformed before action1 (Order of operation)
        {
            switch (action2)  //I didn't include the options for '+' or '-' because the if statement requires action2 to be '*' or '/'.
            {
            case('/'):
                if (num3 == 0)      //The problem I described at the top occurs here and at another place below
                    cout &lt;&lt; "You can't divide by zero.";
                else
                    res = num2 / num3;
                break;
            case('*'):
                res = num2*num3;
                break;
            default:
                cout &lt;&lt; "Input not recognized";
                break;
            }
            switch (action1)    //I didn't include the options for '*' or '/' because the if statement requires action1 to be '+' or '-'.
            {
            case('+'):
                cout &lt;&lt; num1 &lt;&lt; "+" &lt;&lt; num2 &lt;&lt; action2 &lt;&lt; num3 &lt;&lt; "=" &lt;&lt; res + num1;
                break;
            case('-'):
                cout &lt;&lt; num1 &lt;&lt; "-" &lt;&lt; num2 &lt;&lt; action2 &lt;&lt; num3 &lt;&lt; "=" &lt;&lt; res - num1;
                break;
            default:
                cout &lt;&lt; "Input not recognized";
                break;
            }
        }
        else //action1 will be performed before action2 (Order of operation)
        {
            switch (action1)
            {
            case('+'):
                res = num1 + num2;
                break;
            case('-'):
                res = num1 - num2;
                break;
            case('/'):
                if (num2 == 0)     //The problem I described at the top occurs here and at anothe place above
                    cout &lt;&lt; "You can't divide by zero.";
                else
                    res = num1 / num2;
                break;
            case('*'):
                res = num1*num2;
                break;
            case('#'):
                system("PAUSE");
                return 0;
                break;
            default:
                cout &lt;&lt; "Input not recognized";
                break;
            }
            switch (action2)
            {
            case('+'):
                cout &lt;&lt; num1 &lt;&lt; action1 &lt;&lt; num2 &lt;&lt; "+" &lt;&lt; num3 &lt;&lt; "=" &lt;&lt; res + num3;
                break;
            case('-'):
                cout &lt;&lt; num1 &lt;&lt; action1 &lt;&lt; num2 &lt;&lt; "-" &lt;&lt; num3 &lt;&lt; "=" &lt;&lt; res - num3;
                break;
            case('/'):
                if (num3 == 0)
                    cout &lt;&lt; "You can't divide by zero.";
                else
                    res = num2 / num3;
                break;
            case('*'):
                res = num2*num3;
                break;
            case('#'):
                system("PAUSE");
                return 0;
                break;
            default:
                cout &lt;&lt; "Input not recognized";
                break;
            }
        }
        cout &lt;&lt; "\n\n";
    }
}
</code></pre>