aspose file tools*
The moose likes Beginning Java and the fly likes Converting char to int Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Converting char to int" Watch "Converting char to int" New topic
Author

Converting char to int

Joshua Mccartney
Greenhorn

Joined: Apr 25, 2012
Posts: 26
Please help me here..

using if/else condition, that determines if the input is a vowel or consonant.

..


Find the latest job vacancies from the top employers here at QuickList.
We are the prime job site for Filipinos.
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
char primitives are themselves numbers or can be treated as numbers. See if this simple program helps illustrate my point:

See if that coupled with an ASCII table gives you some ideas how to accomplish the assignment.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

Greg Brannon wrote:

Note that the parentheses around 'c' are not necessary; (int) 'c' will work just as fine.
See if that coupled with an ASCII table gives you some ideas how to accomplish the assignment.

And you can find such a table on http://www.asciitable.com.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8427
    
  23

Joshua Mccartney wrote:using if/else condition, that determines if the input is a vowel or consonant.

It really depends on how sophisticated you want this to be; and you also need to allow for the fact that a character may be
  • neither.
  • both (in English, the letter 'y' is often characterised as such).

  • Personally, I'd start out with Character.isLetter() and work from there.

    BTW, I have no idea what this has to do with your subject line.

    Winston


    Isn't it funny how there's always time and money enough to do it WRONG?
    Articles by Winston can be found here
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Converting char to int