Roman Numerals

Discussion in 'Java' started by dragonsfall21@gmail.com, Aug 17, 2007.

  1. Guest

    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.
     
    , Aug 17, 2007
    #1
    1. Advertising

  2. Graham Guest

    On 17 Aug, 09:16, 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"!
     
    Graham, Aug 17, 2007
    #2
    1. Advertising

  3. 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.jspa?threadID=602867&tstart=0
     
    Thomas Schodt, Aug 17, 2007
    #3
  4. 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
     
    Ulrich Eckhardt, Aug 17, 2007
    #4
  5. 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
     
    Patricia Shanahan, Aug 17, 2007
    #5
  6. Lew Guest

    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
     
    Lew, Aug 17, 2007
    #6
  7. Aaron Steed Guest

    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.
     
    Aaron Steed, Aug 17, 2007
    #7
  8. Roedy Green Guest

    On Fri, 17 Aug 2007 08:16:50 -0000, 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
     
    Roedy Green, Aug 17, 2007
    #8
  9. Lew Guest

    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
     
    Lew, Aug 17, 2007
    #9
  10. In comp.lang.java.programmer message <1187338610.108968.86420@q3g2000prf
    ..googlegroups.com>, Fri, 17 Aug 2007 08:16:50,
    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.
     
    Dr J R Stockton, Aug 18, 2007
    #10
  11. Roedy Green Guest

    On Sat, 18 Aug 2007 16:06:38 +0100, Dr J R Stockton
    <> wrote, quoted or indirectly quoted someone
    who said :

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


    see http://mindprod.com/jgloss/romannumerals.html
    for Java source code for Roman to long and long to Roman.
    The Roman to long also accepts strings which are not valid Roman
    numerals and crunches them with the standard algorithm.

    Perhaps someone would like to submit an isValid method to insert ahead
    of it..


    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Aug 18, 2007
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christopher Benson-Manica

    Roman numerals to ints

    Christopher Benson-Manica, Sep 12, 2003, in forum: C Programming
    Replies:
    13
    Views:
    734
    MikeyD
    Sep 17, 2003
  2. ARMAS

    Decimal to Roman Numerals

    ARMAS, Jan 24, 2007, in forum: C Programming
    Replies:
    31
    Views:
    1,743
    Dave Thompson
    Feb 6, 2007
  3. Replies:
    26
    Views:
    1,628
    CBFalconer
    Jan 28, 2008
  4. Ruby Quiz

    [QUIZ] Roman Numerals (#22)

    Ruby Quiz, Mar 4, 2005, in forum: Ruby
    Replies:
    25
    Views:
    369
    James Edward Gray II
    Mar 9, 2005
  5. Ruby Quiz

    [SUMMARY] Roman Numerals (#22)

    Ruby Quiz, Mar 10, 2005, in forum: Ruby
    Replies:
    0
    Views:
    169
    Ruby Quiz
    Mar 10, 2005
Loading...

Share This Page