Hi I'm stuck on this very simple programme. The user is prompted to enter an equation and, if it is not in the format x + y = z I would like it to output an error message. However, if someone typed in 2 + 3 = 3 + 2, the addition 3 + 2 is automatically done and the value of 5 goes into z.

If anyone can help me, I'm very confused!

Thanks!

Code:
#include <iostream>
#include <string>

using namespace std;

int main ()

{	cout << "Please enter an equation."<<endl;
	
        int x, y, result;
	string sign, equals;
    cin >> x >> sign >> y >> equals >> result;
	if
	((cin.fail ()) || (sign != "+") && (sign != "-"))
	{cout << "Invalid Input";
		return 1;}	
 
    bool plus = false;
     if
	(sign == "+") plus = true;		//check for addition/minus
    	{
    	 if
      	(plus)
     	    {if
		(x+y ==  result)
       		cout << "Correct1";
       	     else
      		cout << "Incorrect1";
    	    	}
      	else

  {if

  	(x-y == result)
  	cout << "Correct2";

  	else
  	cout << "Incorrect2";

  	}  
}