The following letters are the only upper case letters with their values:
A. I 1
B. V 5
C. X 10
D. L 50
E. C 100
F. D 500
G. M 1000
Note: the Subtraction Principle is used when the value of the first of two consecutive different Roman Letters is less than the second.
Rule #1: the only time the subtraction principle applies is with the Roman letters I, X, or C. The only letters that can immediately follow I, X, or C with value greater than I, X, or C are the next two letters of higher value. Example: IV is 4, IX is 9, but IL is illegal.
Rule #2: all Roman letters must be in lower case or all Roman letters must be in upper case.
Rule #3: Any sequence of three Roman letters cannot be nondecreasing except if the letters are all the same.
Rule #4: V, L, or D appears at most once.
M, C, or X appears at most four times.
I appears at most three times
Rule #5: M must appear first or second with a C preceding the M.
if M appears second with C preceding M then both M and D cannot appear again in the string.
if M starts the string then there can be at most three M's in a row followed by either CM, or CD, or D or a string of C's.
The rules for what may follow C, X, are similar.
1) Complete and fully-functional working program in executable form as well as complete source code of all work done.
Extra notes: (not included in 'Description')
Input to the program should be either a string of characters representing a Roman Numeral or an Arabic Number and in either case spaces are not allowed.
Error-check the input code whether the input is correct or not. (You may either delete the spaces or copy the input string to another string without spaces.)
The program should either:
1)Convert a string of digits (Max. value, say 3999) to a Roman Numeral using the least amount of letters to represent the Arabic number, or
2) Convert a string of Roman Numerals to an Arabic number in an efficient way.
* please document well; each function should be described as to what the function does and what it returns. each of the function's parameters and local variables should be described as to how the parameters and local variables are modified, and how the parameters are used.
** Functions should be written w/only a few lines of code; they should be tested out completely.
windows (2000, NT, XP, 98)
use MS Visual C++