• Post Reply Bookmark Topic Watch Topic
  • New Topic

Integer values  RSS feed

 
Jay Kamdar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can you change a number from its numerical value to string reprensation?
Ex 5 to "five"
78 to "seventy eight"
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java doesn't have a native way to do it. you'd have to either write your own parser, or find a third-party package that does it.
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This guy has done it in a number of different languages. Source code is available here.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this for a homework assignment? If so, you probably don't want to use Garret's solution since you will miss the whole reason for having this assignment: learning Java!

With that said, how do YOU turn a numerical representation of a number into words? For example, what words do you use to represent 123456? How did you come up with that? you should come up with other examples. Perhaps it is better to start with smaller examples and build up. For now, don't worry about Java. Try to describe the steps you use in your native language. Of coruse, if you want to post your ideas here, you should probably do it in English, but any natural language will work.

Let us know what you come up with and we will be glad to continue to help you.

Layne
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!