title: multiple input validation constraints? c++
body: <p>I have to make sure the letters input consists only of <strong>M, D, C, L, X, V, and I</strong>, which I have done.</p>
  
  <p>My problem is that they are <em>Roman numerals</em>, and I have to also make sure that if a lower value character precedes a higher value character, it follows the rules of Roman numerals:</p>
  
  <ul>
  <li><strong>M, D, C</strong> can be preceded by a character 2 spots lower so <code>CM</code> or <code>DM</code> is okay, but <code>LM</code> is not.</li>
  <li><strong>L, X, V</strong> can only be preceded by a character 1 spot lower so <code>XL</code> is okay, but <code>VL</code> is not.</li>
  </ul>
  
  <p>The 7 letters represent values as follows:</p>
  
  <pre><code>╔════════╦═══════╗
  ║ Symbol ║ Value ║
  ╠════════╬═══════╣
  ║ I      ║ 1     ║
  ║ V      ║ 5     ║
  ║ X      ║ 10    ║
  ║ L      ║ 50    ║
  ║ C      ║ 100   ║
  ║ D      ║ 500   ║
  ║ M      ║ 1,000 ║
  ╚════════╩═══════╝
  </code></pre>
  
  <p>This is what I have thus far:</p>
  
  <pre><code>void romanType::storeRoman()
  {
      locale loc;
      bool valid = true;
  
      do
      {
          valid = true;
          cout &lt;&lt; "please enter a roman numeral using no spaces:" &lt;&lt; endl;
          getline(cin, rNums);
  
          for (i = 0; i &lt; rNums.length(); ++i)
          {
              rNums[i] = toupper(rNums[i], loc);
              if (rNums[i] == 'M' || rNums[i] == 'D' || rNums[i] == 'C' ||
                  rNums[i] == 'L' || rNums[i] == 'X' || rNums[i] == 'V' ||
                  rNums[i] == 'I')
              {
                  continue;
              }
              valid = false;
          }
  
          cout &lt;&lt; "input error please try again\n" &lt;&lt; endl;
      } while (!valid);
  
      /* ... */
  
  }
  </code></pre>
  
  <p>It works as long as all the characters are Roman numerals, but I can't for the life of me figure out how to implement the other 2 constraints I mentioned. I got most of the rest of the program written, but I have spent probably 6-7 hours trying to get this one part too work. Please help. </p>