• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

integer value in Alphabets form Command prompt  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any Class in Java which can takes Integer from Command Prompt and print it in Alphabets.If there is no such class in Java how can we do that???
e.g:
If we give 18 from Command prompt and we get the output "Eighteen"
 
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd have to write a program that parses such input and outputs the appropriate cardinal or ordinal value. There are lots of ways to do this, but there's no class I'm aware of that does it for you.
In fact, this is a good opportunity to think about internationalization. If we're all using the same numeric notation, why not write *one* program that provides language translation, and then produce a file for each language you'd like to do the translations in?
The English file would of course look like:
1=one
2=two
3=three
but if you wanted to support Spanish, you'd have:
1=uno
2=dos
3=tres
then you'd pick which file is appropriate according to the locale of the user's system. Sound interesting?
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
Kamran Mughni Siddiqui
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi dear Michael Ernest,

yes I wanna Write a program with following specifications.... But I have no clue how to began!!!
* Program takes any integer value (b/w 1 to 100) from command prompt.
* Write code to print this integer value in Alphabets.
Example:
1) 59 (input)
Fifty Nine. (output)
2) 76 (input)
Seventy Six (output
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!