This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Converting char to int Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 530
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.


Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19232

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
How To Ask Questions How To Answer Questions
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 4905
    
    7

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?
     
    I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
     
    subject: Converting char to int