title: doing a program using Roman numerals and making them int
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9949071/my-output-is-outputting-correctly">My output is outputting correctly</a>  </p>
  </blockquote>
  
  
  
  <p>this is a homework problem.  I know some of the Roman numerals are not correct.  My teacher doesn't care how to write the number correctly as long as the value is correct.  </p>
  
  <p>I have a few issues with this program.  I don't know any other way to get out of the while loop except asking for the user to press "E".  </p>
  
  <p>Once I do this the output changes to say  <code>cout &lt;&lt; "The first number is " &lt;&lt; RomanNum1 &lt;&lt; endl;</code> is E instead of V or VI or whatever.</p>
  
  <p>I am supposed to use functions and I am not worried about making those.  The bottom part of the program is what my teacher wants the output to look like.  Any help will be greatly appreciated.  </p>
  
  <pre><code>//This programs reads in Roman numerals and outputs the correct numerical value. 
  //This program will do simple math using Roman numerals and output a numerical value
  #include &lt;iostream&gt;
  
  using namespace std;
  
  const char One = 'I';
  const char Five = 'V';
  const char Ten = 'X';
  const char Fifty = 'L';
  const char OneHundred = 'C';
  const char FiveHundred = 'D';
  const char OneThousand = 'M';
  const char EXIT = 'E';
  const char Plus = '+';
  const char Minus = '-';
  const char Times = '*';
  const char Divide = '/';
  
  const int ValueOfOne = 1;
  const int ValueOfFive = 5;
  const int ValueOfTen = 10;
  const int ValueOfFifty = 50;
  const int ValueOfOneHundred = 100;
  const int ValueOfFiveHundred = 500;
  const int ValueOfOneThousand = 1000;
  
  int main (){
      char RomanNum1, RomanNum2;
      char Operation;
      int Answer; 
      string Response;
  
      int ICount = 0;
      int VCount = 0;
      int XCount = 0;
      int LCount = 0;
      int CCount = 0;
      int DCount = 0;
      int MCount = 0;
  
      int Sum = 0;
  
  
      cin &gt;&gt; RomanNum1;
      while (RomanNum1 != EXIT){
  
          if (RomanNum1 == One){
              ICount++;
          }
          else if (RomanNum1 == Five){
              VCount++;
          }
          else if (RomanNum1 == Ten){
              XCount++;
          }
          else if (RomanNum1 == Fifty){
              LCount++;
          }
          else if (RomanNum1 == OneHundred){
              CCount++;
          }
          else if (RomanNum1 == FiveHundred){
              DCount++;
          }
          else if (RomanNum1 == OneThousand){
              MCount++;
          }
          else {
              RomanNum1 = EXIT;
          }
          cin &gt;&gt; RomanNum1;
      }
  
      cin &gt;&gt; RomanNum2;
      while (RomanNum2 != EXIT){
  
          if (RomanNum2 == One){
              ICount++;
          }
          else if (RomanNum2 == Five){
              VCount++;
          }
          else if (RomanNum2 == Ten){
              XCount++;
          }
          else if (RomanNum2 == Fifty){
              LCount++;
          }
          else if (RomanNum2 == OneHundred){
              CCount++;
          }
          else if (RomanNum2 == FiveHundred){
              DCount++;
          }
          else if (RomanNum2 == OneThousand){
              MCount++;
          }
          else {
              RomanNum2 = EXIT;
          }
          cin &gt;&gt; RomanNum2;
      }
  
      cin &gt;&gt; Operation;
      if (Operation == Plus){
          Answer = RomanNum1 + RomanNum2;
          Response = "sum";
      }
      else if (Operation == Minus){
          Answer = RomanNum1 - RomanNum2;
          Response = "difference";
      }
      else if (Operation == Times){
          Answer = RomanNum1 * RomanNum2;
          Response = "product";
      }
      else {
          Answer = RomanNum1 / RomanNum2;
          Response = "quotient";
      }
  
      Sum = ValueOfOne * ICount + ValueOfFive * VCount + ValueOfTen * XCount 
          + ValueOfFifty * LCount + ValueOfOneHundred * CCount + ValueOfFiveHundred 
          * DCount + ValueOfOneThousand * MCount;
  
      cout &lt;&lt; "The first number is " &lt;&lt; RomanNum1 &lt;&lt; endl;
      cout &lt;&lt; "The second number is " &lt;&lt; RomanNum2 &lt;&lt; endl;
      cout &lt;&lt; "Arithmetic operation is " &lt;&lt; Operation &lt;&lt; endl;
      cout &lt;&lt; "The " &lt;&lt; Response &lt;&lt; " of " &lt;&lt; RomanNum1 &lt;&lt; " and " &lt;&lt; RomanNum2 &lt;&lt; " is " &lt;&lt; Sum &lt;&lt; endl;
  
      return 0;
  }
  
  /* here is what the output should be
  Input for Run 1:
  MCCXXVI
  LXVIIII
  +
  DCX
  MCI
  -
  LXVI
  CCLXI
  /
  MD
  XXX
  /
  LXVIIII
  XXVIIII
  *
  
  The output for Test Run 1: 
  MCCXXVI
  The first number is 1226
  LXVIIII
  The second number is 69
  +
  Arithmetic operation is +
  The sum of 1226 and 69 is MCCLXXXXV (1295)
  
  DCX
  The first number is 610
  MCI
  The second number is 1101
  -
  Arithmetic operation is -
  The difference of 610 and 1101 is -CCCCLXXXXI (-491)*/
  </code></pre>