I am still working on this problem.. it does take a bunch of thought....
thanks

Robert Ryan <[EMAIL PROTECTED]> wrote:                               does 
anyone have any idea.
 using get_Roman_token() the result should look like
    II.+III.      =5
    IX.-II.        =7
    IV.*XI.    =44
     
    The result I get is:
    vi Hw3#6.cpp
     g++ Hw3#6.cpp
     ./a.out
    Enter a Roman Numeral to be converted to a decimal:  II. + II.
    1
    That is not a Roman numeral.
    #include<iostream>
   using namespace std;
   int get_Roman_token() { };
   int roman_to_int(char c)
   {
           char roman = c;
           roman = toupper(roman);
           if (roman == 'I') return 1;
           else if(roman == 'V') return 5;
           else if (roman == 'X') return 10;
           else if (roman == 'L') return 50;
           else if (roman == 'C') return 100;
                   else if (roman == 'C') return 100;
                   else if (roman == 'D') return 500;
                   else if (roman == 'M') return 1000;
                   else
                   {
                   cout << "That is not a Roman numeral." << endl;
                   return -1;
                   }
   }
    
         int main()
   {
           char Roman;       int value, c1, c2, first, second;
    
           cout <<"Enter a Roman Numeral to be converted to a decimal:  ";
           while(cin >> Roman)
           {
                   int temp = roman_to_int(Roman);
                   if (temp > 0)
                   cout << temp << endl;
           cin >> c1;
           if(c1== '.')
                   return 0;
           else
                   first = roman_to_int(c1);
           cin >> c2;
           if(c2 == '.')
           {
           cin.putback(c2);
                    return first;
           }
           else
                   second = roman_to_int(c2);
           if (second > first)
                   return second - first;
           else
    
           cout << "Enter a Roman Numeral: ";
           while(cin)
           {
    
                   int temp = get_Roman_token() ;
                   if (temp != 0 )
                           value = value + temp;
                   else
                   {
                           cout<<value;
                           int value = 0;
                   }
           }
   }
    
    
 
 ---------------------------------
 Looking for last minute shopping deals?  Find them fast with Yahoo! Search.
 
 [Non-text portions of this message have been removed]
 
 
     
                               

       
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.

[Non-text portions of this message have been removed]

Reply via email to