Skip to content

Converting roman numerals to decimal numbers is harder than it sounds...

Notifications You must be signed in to change notification settings

ketema/04-Roman-Numerals

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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();

About

Converting roman numerals to decimal numbers is harder than it sounds...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%