OVERVIEW
Write a program to convert roman numerals into their arabic equivalent.
INPUT REQUIREMENTS
Read one or more roman numerals from standard input. Do not display an input prompt. Process one line at a time. Each input line contains only one roman numeral, starting in column one. Assume the characters are all upper case with no embedded blanks.
OUTPUT REQUIREMENTS
The arabic equivalent of each input roman numeral is displayed on standard output, starting in column one.
FUNCTIONAL REQUIREMENTS
Here are the arabic equivalents for roman symbols:
The "basic" roman
symbols
The "auxiliary" roman symbols
I X C M V L D1 10 100 1000 5 50 500
The "auxiliary" roman symbols may only appear once in each Roman numeral. This rule permits XVI but not VIV.
Convert the roman numeral to arabic processing the symbols from left to right according to the following rules:
The
subtracted digit must be at least one tenth of the value of the larger
numeral. Accordingly, ninety-nine is
not
IC but rather XCIX. The XC part represents ninety and the IX adds
the
nine.
ERROR HANDLING REQUIREMENTS
If the input is not a valid roman numeral, display the message "Invalid numeral" and skip the numeral and continue processing the next line.
The program can handle inputs between 1 and 3999.
Submit a printout of executing your program
using
this acceptance test data.