TopcoderArchiveVisit Topcoder
Archive
Algorithm problem

Roman

Problem statement, definition, constraints, and public examples.

Problem Statement

The Romans used seven letters to express all their numbers. A Combination of
letters and their positions could represent any number. 
  I = 1
  V = 5
  X = 10
  L = 50
  C = 100
  D = 500
  M = 1000
To represent the numbers between these seven, a pattern was followed:
  II  = 2
  III = 3
  IV  = 4
Notice the Romans started using a new symbol every fifth element.
Further example: VI = 6, VII = 7, VIII = 8, IX = 9.
Only the highest symbol,  M = 1000, breaks this pattern.
MMMMMMMMMM = 10000
Create a class Roman that has the method romanToArabic, which will convert a
valid Roman numeral String to an integer.

The method returns the integer conversion for the valid Roman numeral.

Here is a method signature (be sure your method is public):
int romanToArabic (String roman)

TopCoder will ensure the following:
- roman will have a max length of 50, consisting of only a valid Roman numeral.

Definition

Class:
Roman
Method:
romanToArabic
Parameters:
String
Returns:
int
Method signature:
int romanToArabic(String param0)
(be sure your method is public)

Constraints

    Examples

      No public sample cases were explicitly marked for this problem in the original data.

      Back to all problems