Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Roman Numerals (http://www.velocityreviews.com/forums/t529857-roman-numerals.html)

 dragonsfall21@gmail.com 08-17-2007 08:16 AM

Roman Numerals

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.

 Graham 08-17-2007 08:59 AM

Re: Roman Numerals

On 17 Aug, 09:16, dragonsfal...@gmail.com wrote:
> 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"!

 Thomas Schodt 08-17-2007 11:04 AM

Re: Roman Numerals

dragonsfall21@gmail.com wrote:
> 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.jsp...02867&tstart=0

 Ulrich Eckhardt 08-17-2007 11:42 AM

Re: Roman Numerals

Graham wrote:
> The Roman Numeral system is already "base-10"!

That's the Arabian one, not the Roman one, IIRC.

Uli

--
Sator Laser GmbH
Geschäftsführer: Ronald Boers, Amtsgericht Hamburg HR B62 932

 Patricia Shanahan 08-17-2007 01:11 PM

Re: Roman Numerals

Ulrich Eckhardt wrote:
> Graham wrote:
>> The Roman Numeral system is already "base-10"!

>
> 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

 Lew 08-17-2007 01:12 PM

Re: Roman Numerals

Ulrich Eckhardt wrote:
> Graham wrote:
>> The Roman Numeral system is already "base-10"!

>
> 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.

--
Lew

 Aaron Steed 08-17-2007 03:39 PM

Re: Roman Numerals

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.

 Roedy Green 08-17-2007 08:18 PM

Re: Roman Numerals

On Fri, 17 Aug 2007 08:16:50 -0000, dragonsfall21@gmail.com wrote,
quoted or indirectly quoted someone who said :

>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
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

 Lew 08-17-2007 08:30 PM

Re: Roman Numerals

Aaron Steed wrote:
> 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?

--
Lew

 Dr J R Stockton 08-18-2007 03:06 PM

Re: Roman Numerals

In comp.lang.java.programmer message <1187338610.108968.86420@q3g2000prf
..googlegroups.com>, Fri, 17 Aug 2007 08:16:50, dragonsfall21@gmail.com
posted:
>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.

<URL:http://www.merlyn.demon.co.uk/programs/cvt_rome.pas> has an
algorithm which could be translated.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.

All times are GMT. The time now is 09:24 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.