Thread: Write a program to interpret roman numerals

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    Write a program to interpret roman numerals

    hi there.! can someone help me to construct the code of this problem..

    Write a program that accepts a number as a Roman numeral and outputs the
    equivalent Arabic (ordinary) numeral. Assume that the Roman numeral is 50 or
    smaller (Roman numeral L or smaller)

    heLp....

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    What have you coded so far?
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    For every I, V, X, L you find in the string, add 1, 5, 10, 50 to a sum respectively.
    Maybe it's easier to go right-to-left... that way if you encounter a unit that's less than the one you just processed, SUBTRACT it instead of ADD.

    This process does not ensure the legality of the Roman numeral but it will work for any legitimate ones. I understand that one cannot do VL for example for 45 but I guess you are not asked to validate input.
    Last edited by nonoob; 03-02-2011 at 03:45 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. im a noob at c++, do you think so?
    By belRasho in forum C++ Programming
    Replies: 6
    Last Post: 04-25-2010, 11:02 PM
  2. Replies: 8
    Last Post: 03-17-2010, 11:18 PM
  3. Program to write to memory map addresses
    By modest in forum C Programming
    Replies: 15
    Last Post: 06-03-2008, 03:20 PM
  4. Replies: 3
    Last Post: 08-21-2006, 06:42 AM
  5. Replies: 3
    Last Post: 03-04-2005, 02:46 PM