Java Program Convert Roman Numerals To Arabic
Write a java program to convert roman numerals into their arabicequivalent.INPUT REQUIREMENTS Read one or more roman numerals from standardinput. Process one line at a time. Each input line contains onlyone roman numeral, starting in column one. Assume the charactersare all upper case with no embedded blanks.OUTPUT REQUIREMENTS The arabic equivalent of each input romannumeral is displayed on standard output, starting in column one.FUNCTIONAL REQUIREMENTS Here are the arabic equivalents for romansymbols: The 'basic' roman symbols The 'auxiliary' roman symbols IX C M V L D 1 10 100 1000 5 50 500Convert the roman numeral to arabic processing the symbols fromleft to right according to the following rules: 1. A symbolfollowing one of greater or equal value adds to its value. (E.g.,XII = 12) 2.
Roman Numerals And Arabic Numerals
A symbol preceding one of greater value subtracts itsvalue.(E.g., IV = 4; XL = 40)ERROR HANDLING REQUIREMENTS In each of the error conditionsbelow, display the given message and skip the numeral and continueprocessing the next line.' Invalid character in input. Valid characters areI,V,X,L,C,D,M.'
Only the listed characters are valid.' Invalid numeral: can't subtract auxiliary symbol.'
It is notpermitted to subtract an 'auxiliary' symbol. (CML, not LM = 950;XLV not VL, = 45).'
Invalid numeral: two consecutive subtractions.' Can't do twosubtractions in a row, thus LIVX is illegal.' Invalid numeral: additions don't decrease.' Additions mustdecrease, as you go from left to right.
Thus, each symbol addedmust have a value equal or less than the last symbol which wasadded. Thus, LIIX is wrong, cause we added L, added I, subtractedI, then try to add X. Expert Answer.