title: C++ Arabic to roman numeral converter - of input validation loops
body: <p>The purpose of this program is to take an input of an arabic number and return the equivelant roman numeral. it needs to reject input less than 0 and greater than 3999, but also end on an input of ANY NEGATIVE NUMBER. Also needs an input fail catch for entering a letter instead of an integer. (completely clueless on this part?!) 
  My question is what order should these conditional statement be in so that the program doesnt just return invalid input for a negative number, it ends the program. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  #include &lt;iomanip&gt;
  using namespace std;
  
  string convert(int digit, string low, string mid, string high);
  
  int main()
  {
      const int MAX_INPUT = 3999, MIN_INPUT = 0, // These constants hold high and low integer numbers,
                ARRAY_SIZE = 4;                  // and the array size declarator.
      string answers[ARRAY_SIZE] = { "", "", "", "" }; //An  array of string to hold the output from the convert function.
      int accumulator = 0; // Variable to hold number of arabic numbers converted.
      int userNum = 0;
  
      do {
          cout &lt;&lt; "Enter a negative number to end the program.\n";
          cout &lt;&lt; "Enter an arabic number between 1 and 3999: ";
          cin &gt;&gt; userNum;;
  
          if (userNum &lt; 0)
          {
              cout &lt;&lt; "Exiting program:";
              break;
  
              while (userNum &lt;= MIN_INPUT || userNum &gt;= MAX_INPUT)
              {
                  cout &lt;&lt; "\nInvalid Value. Number must be between 1 and 3999: ";
                  cin &gt;&gt; userNum;
              }
          }
  
          int thous = userNum / 1000;
          cout &lt;&lt; thous;
  
          int hund = userNum % 1000 / 100;
          cout &lt;&lt; "hundreds:" &lt;&lt; hund;
  
          int tens = userNum % 100 / 10;
          cout &lt;&lt; "tens:" &lt;&lt; tens;
  
          int ones = userNum % 10 / 1;
          cout &lt;&lt; "Ones: " &lt;&lt; ones &lt;&lt; endl;
  
  
          answers[0] = convert(thous, "M", "M", "M");
          answers[1] = convert(hund, "C", "D", "M");
  
          answers[2] = convert(tens, "X", "L", "C");
          answers[3] = convert(ones, "I", "V", "X");
  
          cout &lt;&lt; answers[0] &lt;&lt; endl &lt;&lt; answers[1] &lt;&lt; endl &lt;&lt; answers[2];
          cout &lt;&lt; endl &lt;&lt; answers[3] &lt;&lt; endl;
  
  
      } while (userNum &gt; 0);
  
      system("PAUSE");
      return 0;
  
  }
  string convert(int digit, string low, string mid, string high)
  {
  
      cout &lt;&lt; digit &lt;&lt; endl;
  
      if (digit == 1)
      {
          return low;
      }
      if (digit == 2)
      {
          return low + low;
      }
      if (digit == 3)
      {
          return low + low + low;
      }
      if (digit == 4)
      {
          return low + mid;
      }
      if (digit == 5)
      {
          return mid;
      }
      if (digit == 6)
      {
          return mid + low;
      }
      if (digit == 7)
      {
          return mid + low + low;
      }
      if (digit == 8)
      {
          return mid + low + low + low;
      }
      if (digit == 9)
      {
          return low + high;
      }
      if (digit == 0)
      {
          return "";
      }
  }
  </code></pre>