#include <iostream>

using namespace std;


int main()
{
  restart:
  int a,b,c,x;

  cout << "Welcome to the advanced arithmetic calculator.\nWhat do you want to do?\n1)Add\n2)Sub\n3)Mul\n4)Div\n\n";
  cin >> x;

  if(x==1||x==2||x==3||x==4)
  {
      cout << "\nEnter first number.\n\n";
      cin >> a;

      cout << "\nEnter second number.\n\n";
      cin >> b;

      if(x==1)
      {
        c=a+b;
      }

      else if(x==2)
      {
          c=a-b;
      }

      else if(x==3)
      {
          c=a*b;
      }
      else if(x==4 && b!=0)
      {
          c=a/b;

      }
      else if(x==4 && b==0)
      {
          cout << "\nUNDEFINED.\n\n";
          goto restart;
      }

      cout <<endl<< c <<" is the answer.\n\n";
  }
  else
  {
      cout << "\nERROR\n\n-------------\n\n";
      goto restart;
  }

  //-------------------------End of first calc

  cout <<"What would you like to do next? Would you like to 1)Restart or 2)Exit?\n\n";
  cin >> x;

  if(x==1)
  {
      goto restart;
  }

  else
  {
      cout << "\nBye.\n\n";
      return 0;
  }
}