This website is preserved for historical and scholarly reference and is no longer actively maintained.
CpSc 210, Section 1
Assignment 1
September 17, 2001
Due: Tuesday, September 25 at 11:59 p.m.
Assignment: Finding the integer equivalent to a Roman number
Total point value of assignment: 100 points
Not accepted late.
This assignment is to be done INDIVIDUALLY.
Assignment: Design and implement a class, Roman, which must be stored in a
file named Roman.java. (20 point deduction for failure to name file
correctly!) Roman.java must contain at least the following methods:
public static boolean isPossibleRoman ( String s )
// Pre: String s is not empty.
// Post: Returns true if the String contains only the
// capital letters I, V, X, L, C, M, and D.
// Otherwise, isPossibleRoman returns false
public static int translate ( String s )
// Pre: String s contains a valid Roman numeral
// Post: The arabic equivalent of the Roman numeral is returned
You may include any additional methods you need. Additional methods
should be private instead of public.
You may assume the following:
I (capital letter I) is one
V (capital letter V) is five
X (capital letter X) is ten
L (capital letter L) is fifty
C (capital letter C) is one hundred
D (capital letter D) is five hundred
M (capital letter M) is one thousand
Strings will be equivalent to numbers in the range 1 .. 3899.
Since there is no zero, the empty String is not allowed.
Sample results are:
translate ( "VI" ) will return 6
translate ( "XII" ) will return 12
translate ( "XIX" ) will return 19
translate ( "XXX" ) will return 30
translate ( "XLIX" ) will return 49
translate ( "LXXXV" ) will return 85
translate ( "MMI" ) will return 2001
translate ( "MMCDL" ) will return 2450
The method translate should work for any String s. Code that contains
specific tests for the above strings such as "if ( s.equals("XIX")) ... "
will be considered poor programming practice and points will be
appropriately deducted.
ROMAN NUMERATION. (from page 91, Mathematical Ideas by Miller and Heeren)
"You are probably familiar with the Roman numeration system, which
is still used today, mainly for decorative purposes, on clock faces, for
heading numbers in outlines, for chapter numbers in books, and so on.
What are the characteristics of the Roman method? Apparently, base 10
appealed to them also, but they introduced "extra" symbols to reduce the
number of repetitions within a group. The Roman symbol for 1 was similar
to that of the Egyptians, with repetitions of this symbol used for 2,
and 3. Instead of continuing in this way up to 9, though, they introduced
a distinct symbol for 5. Likewise, their symbol for 10 was repeated for
20 and 30, but a distinct symbol denoted 50. Other symbols denoted 500,
5000, 50,000, and 500,000. Roman numeration is like a base 10 simple
grouping system with a secondary base 5 grouping. More symbols had to be
used than in a pure simple grouping system, but the necessity of
repetition was reduced.
"The Romans also saved space by using subtractiion. A symbol to the left of
another symbol of larger value indicated that the smaller value was to be
subtracted from the larger value on the right. For example, 9 was written
IX (10 minus 1) rather than VIIII (5 plus 4). The same method was often
used to write 4 as IV rather than IIII. ..."
Note that more than a single symbol is never subtracted. For example, VII
is always used to represent seven. IIX is never used to represent 7.
Grading Rubric:
10 pts. reasonable attempt to solve problem as assigned
10 pts. also compiles
10 pts. style standards (includes clarity)
The following 70 points are available only for code that compiles
and runs without error.
50 pts. works for specified testDriver
20 pts. works for our testDriver
You will be sent (by email) an outline for this program, which contains
our testDriver. Do not change the main program sent by email except to
add to the end of the main method. The 50 pts. for the specified
testDriver will be based on the test driver sent to you (unchanged).
Thus, any changes/additions you make to the test driver must be appended
to the end of the main method. You will receive credit for every correct
answer for the specified test driver until your program terminates
(except as excluded above).
Other requirements:
The first operation of your main program must be to print "CPSC 210", your name, the assignment number, and a brief description of the assignment.
Follow the style standards to be found on your instructor's
web page for CPSC 210.
Submit your program using the handin command. There is a link to
the handin description on the CPSC 210 lab page (www.cs.clemson.edu/~lab210).