Actually, the program is correct as the code is interpreting MMIIIX as 2000 + 2 + 9 = 2011!
So the program is right. But I didn't want to write a book about the program. I guess I needed to explain how Roman Numerals work for those not versed in them.
To read for yourself, go to:
https://en.wikipedia.org/wiki/Roman_numeralsThe actual way or variants of how the Romans used their numbering system allowed for smaller numbers to appear anywhere.
Most people do not realize that when the Romans first used their numbering system, there was no "reduction" system in place. So the way you'd interpret these is to add all the representations from left to right. (M+M+I+I+I+X = 1000+1000+1+1+1+10 = 2013 is just as valid an interpretation as M+M+I+I+IX or 1000+1000+1+1+9
When the Roman's came up with "reduction," it was not exclusively used. Both systems were in use during the entire Roman Empire.
My program can be made to add the Roman Numerals the original way by adding a switch to bypass the "additive subtraction."
MMIIIX (200+II+IX) if NOT correct !!!
There can be only one character coming in reduction of the following one:
4 = IV
9 = IX
90 = XC
49=IL
99=IC
400 = CD
900 = CM aso
Apart from the number coming in reduction before the following one (here IX=9), the letters must follow the decreasing order of their value.
The value MMIIIX is a fancy, because then two "I" are smaller as X !!!
2000 + 2 + 9 ---> oh ! 2 is less than 9 !!! Not possible in roman numeral !!!
2011= 2000+10+1 = MMXI
Always, yes, always, from biggest to smalest !!!