• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Representing integer value to char

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ??
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Abhi,

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

Joyce
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code for this is :
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Joyce and thanks everyone for such a help.

I'll try to get it done by myself now.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic