Pages

Converting Roman Numerals To Decimal

In this post we will write a java program to convert Roman Number to Decimal. Before start our program, lets see what are the roman numbers and its decimal values below.

Roman Numbers and its decimal values:
Roman Symbol
Decimal value
I
1
IV
4
V
5
IX
9
X
10
XL
40
L
50
XC
90
C
100
CD
400
D
500
CM
900
M
1000

Decimal Forming Rules:

1. When a symbol appears after a larger or equal symbol, then it is added

  • VI = V + I = 5 + 1 = 6
  • XXI = X + X + I = 10 + 10 + 1 = 21

2. But if the symbol appears before a larger symbol, the it is subtracted

  • IV = V - I = 5 - 1 = 4
  • IX = X - I = 10 - 1 = 9
Java Program:


Output:
Enter roman value : VI
It's Decimal value : 6

Enter roman value : XC
It's Decimal value : 90

Enter roman value : MCMLXXXIV
It's Decimal value : 1984

No comments:

Post a Comment