File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Representing integer value to char Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Representing integer value to char" Watch "Representing integer value to char" New topic
Author

Representing integer value to char

Abhi Dhanda
Greenhorn

Joined: Sep 09, 2004
Posts: 6
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

Joined: Jul 11, 2003
Posts: 1392
Hi Abhi,

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

Joyce
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
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.


Mike Gershman
SCJP 1.4, SCWCD in process
Abhi Dhanda
Greenhorn

Joined: Sep 09, 2004
Posts: 6
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

Joined: Sep 09, 2004
Posts: 6
The code for this is :
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
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

Joined: Sep 09, 2004
Posts: 6
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

Joined: Jul 11, 2003
Posts: 1392
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

Joined: Jul 11, 2003
Posts: 1392
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

Joined: Sep 09, 2004
Posts: 6
Thanks Joyce and thanks everyone for such a help.

I'll try to get it done by myself now.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Representing integer value to char
 
Similar Threads
forDigit ()?????
Problem in execution of code
Ordering of AlphaNumeric No. in ascending Order
Checking if a char variable is octal
Conversion from ASCII to integer.