Roman Numerals

D

dragonsfall21

hello fellow java programmers. I was wondering if anybody could help
think of a good way to convert roman number in to a base 10 number.
My first thought was to create parallel arrays for numerals and
letters, and the use a for loop, combined with if statements: if
substring of starting letter sequence equals anything from the array,
take that off and add the coresponding numeral to the final result.
But this got really bulky and overbearing. was looking for a better
way.

Thanks.
 
G

Graham

hello fellow java programmers. I was wondering if anybody could help
think of a good way to convert roman number in to a base 10 number.
My first thought was to create parallel arrays for numerals and
letters, and the use a for loop, combined with if statements: if
substring of starting letter sequence equals anything from the array,
take that off and add the coresponding numeral to the final result.
But this got really bulky and overbearing. was looking for a better
way.

Thanks.

The Roman Numeral system is already "base-10"!
 
T

Thomas Schodt

hello fellow java programmers. I was wondering if anybody could help
think of a good way to convert roman number in to a base 10 number.
My first thought was to create parallel arrays for numerals and
letters, and the use a for loop, combined with if statements: if
substring of starting letter sequence equals anything from the array,
take that off and add the coresponding numeral to the final result.
But this got really bulky and overbearing. was looking for a better
way.

http://www.google.com/search?q=java+roman+numerals

http://forum.java.sun.com/thread.jspa?threadID=602867&tstart=0
 
P

Patricia Shanahan

Ulrich said:
That's the Arabian one, not the Roman one, IIRC.

Uli

I'm not sure which of two concepts is meant by "base-10" in this context:

1. Being based on powers of ten: Yes. Each character in a Roman Numeral
number represents either a power of ten, or five times a power of ten.

2. Being a positional system in which moving a digit one place
multiplies or divides its value by 10? No. Roman numerals are not
primarily a positional system.

Patricia
 
L

Lew

Ulrich said:
That's the Arabian one, not the Roman one, IIRC.

"Arabic", not "Arabian".

Roman numerals are in base 10, in the sense that they are based on a counting
system base 10. They are not in base 10 in the sense that they are not based
on a power-of-10 notation.

This is a standard homework problem. Go to http://mindprod.com and look at
the "Getting Started" link for how to get started on a programming problem.

If you actually /think/ about the problem you'll come up with the code. This
is the sort of thing the OP should figure out for themselves.
 
A

Aaron Steed

oh i knew it was base 10, i just meant in numerals. I have the
program working, i was basically asking if anybody knew of a more
efficient way to convert them.
 
R

Roedy Green

hello fellow java programmers. I was wondering if anybody could help
think of a good way to convert roman number in to a base 10 number.

The code for going the other way, a much simpler task, is at
http://mindprod.com/products1.html#INWORDS

You could probably find the code you want with google.com, or at least
the algorithm, or the code is some other language.

In Canada you learn to read Roman numerals in about grade 4. Just
write down a number of examples, and do it by hand, and then write an
algorithm to formalize what you are doing. By hand, you pick out
patterns very easily. In your code you will have to find them with a
finite state automaton, or a parser.
See http://mindprod.com/jgloss/finitestate.html
http://mindprod.com/jgloss/parser.html
 
L

Lew

Aaron said:
oh i knew it was base 10, i just meant in numerals. I have the
program working, i was basically asking if anybody knew of a more
efficient way to convert them.

More efficient than what?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top