roman numeral converter

I need a small c++ program to convert roman numerals to decimal. Any takers? Must provide souce...
datamikeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ocuranceConnect With a Mentor Commented:
Pass in the char array as a roman numeral, and Roman2Decimal will return the value that you're looking for.

int Roman2Decimal(const char *Roman)
{
   int Total = 0;

   for(int i = 0; i < strlen(Roman); i++)
   {
            if(GetValue(Roman[i]) < GetValue(Roman[i + 1]))
                Total -= GetValue(Roman[i]);
        else
                Total += GetValue(Roman[i]);

       }

    return Total;

}

int GetValue(char numeral)
{
   int value = 0;

   switch(numeral)
   {
      case 'I':
        value = 1;
         break;

      case 'V':
        value = 5;
        break;

      case 'X':
         value = 10;
         break;

     etc.............
   }
   return value;
}



Good Luck,
Roger
0
 
ocuranceCommented:
Did this answer your question sufficiently?  Are you going to grade this now?
0
 
datamikeAuthor Commented:
could you provide an entire c++ program? could you also do it without using pointers? if you can do these tasks, I'll give you an 'a' and an extra 100 points for 250 total.
0
 
ocuranceCommented:
Give me your email address and I'll send you the whole program code.
0
 
datamikeAuthor Commented:
send to: datamike@interaccess.com
0
All Courses

From novice to tech pro — start learning today.