title: C++: Confusion on converting integers to roman numerals
body: <p>I'm working on a program for my C++ course. The guidelines are to create a converter that turns integers to roman numerals, the specifications being that I must use at least one while statement,  do while statement, and one switch. </p>
  
  <p>My code isworking for the most part, but I can't involve special cases involving 4 and 9 (such as (4, 14, 24 34, etc) 40, (140, 240, etc) 400, (1400, 2400, 3400, etc) and (9, 19, 29, 39, etc) 90, (190, 290, etc) 900, 9000)) to work for me. This is the code I have at this point: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  int main( )
  { 
     cout &lt;&lt; "Please enter  an interger." &lt;&lt; endl;
     int num = 0;
     cin &gt;&gt; num;
     string rep = "";     
  
  
       switch(num)
     {
        case 40:                                    
        rep += "XL"; 
        num -= 40;                                   
        break;                                     
        case 90:
        rep += "XC";
        num -= 90;
        break;
     }
  
  
        if (num &gt;= 1000){
           rep += string(num / 1000,'M');
           num %= 1000;
        }
        if (num &gt;= 500){
            rep += string(num / 500,'D');
            num %= 500;
        }
        if (num &gt;= 100){
            rep += string(num / 100,'C');
            num %= 100;
  
        }
        if (num &gt;= 50){
            rep += string(num / 50,'L');
            num %= 50;
  
        }
        if (num &gt;= 10){
            rep += string(num / 10,'X');
            num %= 10;
        }
        if (num &gt;= 5){
            rep += string(num / 5,'V');
            num %= 5;
        }    
        if (num &gt;= 1){
           rep += string(num,'I');
           num %= 1;
        }
  
  
        cout &lt;&lt; num &lt;&lt; endl;
        cout &lt;&lt; rep &lt;&lt; endl;
  
      return 0;  
  }
  </code></pre>