a JAVA program that would input a string and display the total number of vowels and total number of consonants. (use method)
Example:
Input a string: beautiful
Total Vowels: 5
Total Consonants: 4

Can someone give me a code for this? ...

Yes. I won't though. Read the terms and conditions of this site, again, please. You have read them at least once, already, right?

Guys, please drop this mocking it doesn't help any of us.

@loozax you should be aware that there is a rule on this forum which says "We only give homework help to those who show effort". So presuming that you still on this task I would recommend you do some coding, post code and ask questions related to code or specific issue and not general request to do your homework

Oh, I had to do this one too!

I suggest you start by putting everything you can down in code and then when/if you get stuck the post what you have and we can help you through it. The toughest part is getting yourself started.

Identify what the program needs to do very specifically.

  • Prompt the user to input a String
  • Separate the String into separate characters
  • Identify the case of each letter
  • Tally up the number of each type of character
  • Ignore the characters that aren't letters
  • Display the final tally

Briefly list out ways in which you could do each component and then you'll have a much better idea of how to string everything together with code.

To start you off:
Everything you need should be on these two pages:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Character.html
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html

Good luck.

Comments
Excellent ideas :)
This article has been dead for over six months. Start a new discussion instead.