Results 1 to 6 of 6
  1. #1
    javanewbie is offline Member
    Join Date
    Jun 2008
    Location
    Australia
    Posts
    43
    Rep Power
    0

    Default Convert Currency to Words in English

    The program will accept a double-data type input from a user. Function of the program is to convert the number inputted to its equivalent words.

    eg.

    12345.67 = Twelve thousand and three hundred and forty five dollars and sixty seven cents

    765.43 = seven hundred and sixty five dollars and forty three cents


    Oh. By the way, using the following methods on the java.lang.String is much appreciated.

    * charAt()
    * length()
    * trim()
    * valueOf() - overload
    * toCharArray()
    * indexOf(String str)
    * indexOf(String str, int fromIndex)


    Does anybody have the idea here?

  2. #2
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default

    Hi,
    Try with the following steps.
    1. Get the double value and convert into string.
    2. Check if that String say str has a "."
    3. If str has a "." then crete 2 substrings of str say str1=765 and str2=43 by using indexOf(".") & susstring() methodsand if it does not have then u can leave it as it is.
    4.Check the length of each string say 3 for 765.
    5.Use string tokenizer or using a normal string methods get each digit.
    6.then use concat() function of string with each digit and the value like dollars/cents depending on the the place of the digit.

    Go ahead All the Best...
    To finish sooner, take your own time....
    Nivedithaaaa

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    When concat the strings you have think about additional strings too, like 'thousand' 'hundred' and so on.

  4. #4
    kicksfanscom is offline Member
    Join Date
    Jun 2008
    Posts
    15
    Rep Power
    0

    Red face I have been looking for sites like this for a long time. Thank you!.txt

    I have been looking for sites like this for a long time. Thank you!

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by kicksfanscom View Post
    I have been looking for sites like this for a long time. Thank you!
    Are you talking about our community? Nice to here your comments. ;)

  6. #6
    Pascal Nouma is offline Member
    Join Date
    Mar 2009
    Posts
    3
    Rep Power
    0

Similar Threads

  1. Be smart in English...
    By Eranga in forum Entertainment
    Replies: 22
    Last Post: 11-10-2009, 11:14 AM
  2. Replies: 1
    Last Post: 07-02-2008, 02:58 PM
  3. Formatting a number to currency
    By Java Tip in forum java.text
    Replies: 0
    Last Post: 04-16-2008, 11:59 PM
  4. Setting currency
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-16-2007, 03:08 PM
  5. Menues in english and spanish languages
    By aleplgr in forum AWT / Swing
    Replies: 0
    Last Post: 08-06-2007, 11:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •