Question
I would need a program that converts roman numerals into their arabic equivalent. Program should read a roman number string and should print on the
I would need a program that converts roman numerals into their arabic equivalent. Program should read a roman number string and should print on the screen either the arabicnumber that corresponds to it or the first rule number that is not observed in the string from the left to right. If more than one rule is not observed in the roman number it should print only ONE rule from the below mentioned rules (1 to 8).
"1 Invalid character in input. Valid characters are I,V,X,L,C,D,M." RULE:Only the listed characters are valid."
"2 Invalid numeral: can't subtract auxiliary symbol." RULE:It is not permitted to subtract an "auxiliary" symbol. (CML, not LM = 950; XLV not VL, = 45)."
"3 Invalid numeral: two consecutive subtractions." RULE:Can't do two subtractions in a row, thus LIVX is illegal."
"4 Invalid numeral: additions don't decrease." RULE:Additions must decrease, as you go from left to right. Thus, each symbol added must have a value equal or less than the last symbol which was added. LIIX is wrong, cause after adding L, then I, subtracted I, then trying to add X."
"5 Invalid repetition of V, L or D": RULE The symbols V, L and D are never repeated."
"6 Too long repetition": RULEA symbol is not repeated more than three times."
"7 Wrong subtraction" RULEThe symbol I can be subtracted from V and X only. The symbol X can be subtracted from L and C only. The symbol C can be subtracted from D and M."
"8 Cannot subtract more than one from a particular symbol" RULEA symbol cannot be subtracted more than once from a particular symbol of greater value. In other words, a symbol is not repeated on the left side of a symbol. Eg, 98 is written as XCVIII and not as IIC."
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started