Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 574 Bytes

README.textile

File metadata and controls

32 lines (24 loc) · 574 Bytes

Roman Numerals

Given a Roman numeral, convert to Decimal format; given a Decimal number, convert to Roman numeral.

Decimal values for Roman Numerals

I = 1
V = 5
X = 10
L = 50
C = 100
D = 500
M = 1000

Example data sets:

III = 1 + 1 + 1 = 3
VII = 5 + 1 + 1 = 7
IV = 5 – 1 = 4
LL = 50 + 50 = 100 = ERROR!
XX = 10 + 10 = 20
LC = 100 – 50 = 50 = ERROR!
MCMLVII = 1000 + ( 1000 – 100 ) + 50 + ( 5 + 1 + 1 ) = 1957
CC = 100 + 100 = 200
XC = 100 – 10 = 90
IC = 100 – 1 = 99 = ERROR

Proposed Classes

$Number = new RomanNumeral(‘XVII’);

$Number→toInt();