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

Recommended Answers

All 6 Replies

try for your self.
if you face problem while trying post here.

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?

System.out.println("I am not putting any effort to code my homework");
commented: Nice! +36

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.

commented: Excellent ideas :) +36
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.