Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Question: Converting number to words.

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    13
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Question: Converting number to words.

    Hi, how can I convert numbers into words without using arrays? or is it possible not to use arrays?


  2. #2
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Question: Converting number to words.

    i think you should really use a list..

    or check the API if theres any method that converts a number into a String/word

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Question: Converting number to words.

    Integer.toString() converts an int to a string....after which you can stitch the strings together.
    Last edited by copeg; December 30th, 2009 at 10:30 PM.

  4. #4
    Member
    Join Date
    Dec 2009
    Location
    UK
    Posts
    58
    My Mood
    Sleepy
    Thanks
    2
    Thanked 3 Times in 2 Posts

    Default Re: Question: Converting number to words.

    So, if I want to do the opposite, does String.toInteger () work?

    Regards,

    Shaun.

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Question: Converting number to words.

    Quote Originally Posted by ShaunB View Post
    So, if I want to do the opposite, does String.toInteger () work?.
    Integer.parseInt() is what you are looking for. If you are unsure that the String is an integer, be sure to validate it before, or catch any NumberFormatExceptions that could be thrown

    see: how to convert string to int

  6. #6
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Question: Converting number to words.

    hhaha i thought he was asking how to convert a number into a words LITERALLY

    like 1 - one..! 1000 - one thousand.... deym...!

  7. #7
    Member
    Join Date
    Dec 2009
    Location
    UK
    Posts
    58
    My Mood
    Sleepy
    Thanks
    2
    Thanked 3 Times in 2 Posts

    Default Re: Question: Converting number to words.

    lol, no. I need to get the value of a string. In Olde BASIC (Sinclair, Commodore etc...) you would use something like VAL or VAL$. Ie, LET A=VAL "100" or LET B=VAL B$ would give you 100 or the literal value of B$ as long as B$ only contains numbers and not letters or other characters.

    Regards,

    Shaun.

Similar Threads

  1. How to convert GSM 6.10 wav file to MP3/PCM/OGG/AU format using JAVA?
    By expertise in forum Java ME (Mobile Edition)
    Replies: 4
    Last Post: April 11th, 2014, 02:13 AM
  2. Converting Hex to Decimal
    By r2ro_serolf in forum Java Theory & Questions
    Replies: 10
    Last Post: September 4th, 2011, 04:29 PM
  3. Question: Converting cents to dollars.
    By shamed in forum Java Theory & Questions
    Replies: 4
    Last Post: December 26th, 2009, 06:33 PM
  4. Adding Marathi words to MySQL table
    By vaishali in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: July 8th, 2009, 06:43 AM
  5. Replies: 4
    Last Post: May 1st, 2009, 03:32 PM