Skip to main content
ICT
Lesson A10 - The String Class
 
Main Previous
Title Page >  
Summary >  
Lesson A1 >  
Lesson A2 >  
Lesson A3 >  
Lesson A4 >  
Lesson A5 >  
Lesson A6 >  
Lesson A7 >  
Lesson A8 >  
Lesson A9 >  
Lesson A10 >  
Lesson A11 >  
Lesson A12 >  
Lesson A13 >  
Lesson A14 >  
Lesson A15 >  
Lesson A16 >  
Lesson A17 >  
Lesson A18 >  
Lesson A19 >  
Lesson A20 >  
Lesson A21 >  
Lesson A22 >  
Lesson AB23 >  
Lesson AB24 >  
Lesson AB25 >  
Lesson AB26 >  
Lesson AB27 >  
Lesson AB28 >  
Lesson AB29 >  
Lesson AB30 >  
Lesson AB31 >  
Lesson AB32 >  
Lesson AB33 >  
Vocabulary >  
 

LAB ASSIGNMENT A10.3 page 17 of 17

RomanNumerals

Assignment:

  1. You will create a class with two public static methods. One will receive an int number and return a String with that int converted into Roman Numerals. The other method will receive a String of Roman Numerals and return the int value of the Roman Numerals.

  2. These two methods are static because there is no reason to create an object just to run these calculations.

  3. Think of using helper methods to reuse algorithms needed to solve these problems.

  4. Assume that your client gives you valid Roman Numerals and the Arabic numbers are positive and less than 4000.

Instructions:

Roman Numerals work differently than our normal Arabic number system. Roman Numerals have symbols, all in capital letters (and sometimes in lower case), which represent Arabic numbers. Roman Numerals have been used for identifying movie sequels (i.e., The Godfather: Part II), for publication copyright dates, for numbering monarchs such as Queen Elizabeth II, and for numbering Super Bowls. See the following table for the Roman Numerals symbols up to 1000.

Roman Numeral
Arabic Number
I or i
1
V
5
X
10
L
50
C
100
D
500
M
1000

Usually, numbers are formed by stringing the Roman numerals together and adding them up to make the required number (i.e., II = 2, or XII = 12). If smaller numbers follow larger numbers, the numbers are added (i.e., VIII = 5 + 3 or 8), but if a smaller number precedes a larger number, the smaller number is subtracted from the larger number (i.e., IX = 10 - 1 or 9).

There is shorthand for the case when there are four of the same symbols in a row. Instead of IIII for 4, it is written as IV or 5 - 1 = 4. This only applies to symbols that represent powers of ten. Since our numbers will be less than 4000, this only makes sense for I, X and C. Some people think this means you can write IC for 99 but that is not going to be allowed. When using this shortcut, a symbol can only precede a symbol whose value is 5 or 10 times its own value. For example, X (10) can only precede L (50) or C (100). So XL (40) is acceptable, but XD (490?) is not.

Roman Numeral
Arabic Number
XLVI
46
XCIX
99
MDCCCXIX
1819
DCXLIX
649
MCMLXXXIII
1983

 

Main Previous
Contact
 © ICT 2006, All Rights Reserved.