• Post Reply Bookmark Topic Watch Topic
  • New Topic

Representing integer value to char  RSS feed

 
Abhi Dhanda
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to input an integer value and want the program to spell out that value as output.
For this I wrote this piece of code -


Can somone help me out here that why it's not goving me an output ??
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Abhi,

Are you trying to write a program like Cattle Drive assignment Java-4a?

Joyce
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your program has some unnecessary lines, but it still works with the input arguments 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9. Any other arguments give the null character ('\u0000'), which doesn't print anything.

If you're not sure about the input argument, why not print out args[0] before you parse it?

Also, see if you can fnd the unnecessary lines in your code.
 
Abhi Dhanda
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies.

yeah Joyce, am trying to do the cattle drive assignments. And this one is 4(a).

And I want to do like.. If I 'll input the digital value 22, then my program will display it as character "twenty-two".

So Mike, i tried with 0,1,2....8,9. But It returns me only the same integer representation on my output screen. And also why it returns null for any value bigger than 9.

Thanks.
 
Abhi Dhanda
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code for this is :
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look up the forDigit() method in the doc, you'll see that it is doing its job returning the character representation of the integer m in the 10 based number system.
 
Abhi Dhanda
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike Gershman:
If you look up the forDigit() method in the doc, you'll see that it is doing its job returning the character representation of the integer m in the 10 based number system.


Can you help me to get the thing what I want?
Can you please suggest me the method.

Thanks.
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhi, here is an example for 0-9 input. You can try out 0-99.



Just like the hint given in the assignment 4a, you need an array or other collection to hold the names.

Have fun!

Joyce
[ October 04, 2004: Message edited by: Joyce Lee ]
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you encounter any problem while working on the Cattle Drive assignments, you can come to Cattle Drive Forum to ask for help or search for clue.

Joyce
 
Abhi Dhanda
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joyce and thanks everyone for such a help.

I'll try to get it done by myself now.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!