1. Ask the user to enter a number in roman numerals.
2. Convert the number to a decimal value.
3. Output the decimal value.
4. Output an error message if the roman numeral is not in the correct form.
5. Go to step 1. (Continue until the user indicates they want to quit.)
1. Put the string conversion code in a function.
2. Convert lowercase input characters to uppercase for processing
and displaying.
Roman numerals (Wikipedia)
RegEx Roman Numerals - Computerphile
Roman Numeral | Value |
---|---|
I | 1 |
II | 2 |
III | 3 |
IV | 4 |
V | 5 |
VI | 6 |
VII | 7 |
VIII | 8 |
VIIII | 9 |
Symbol | Value |
---|---|
I | 1 |
V | 5 |
X | 10 |
L | 50 |
C | 100 |
D | 500 |
M | 1,000 |
Example | Value |
---|---|
MCDXCII | 1492 |
MMXX | 2020 |
MCMXLIV | 1944 |
XCIX | 99 |
Rules for writing roman numerals from www.cuemath.com/numbers/roman-numerals/