1 Replies - 993 Views - Last Post: 07 July 2012 - 02:52 PM Rate Topic: -----

#1 Fruitcakeboss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-July 12

How to print the number of vowels or consonants in a sentence.

Posted 07 July 2012 - 02:24 PM

Hello everyone!

I need to understand how to print the number of vowels or consonants in a sentence only using loops,if,and switches.
I can't use a scanner.

Any advice will be really appreciated.
Is This A Good Question/Topic? 0
  • +

Replies To: How to print the number of vowels or consonants in a sentence.

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2100
  • View blog
  • Posts: 3,197
  • Joined: 21-June 11

Re: How to print the number of vowels or consonants in a sentence.

Posted 07 July 2012 - 02:52 PM

If you have the sentence as a string, you do it by iterating over the string character by character (using the charAt method in a for-loop) and increasing a different counter at each iteration depending on whether the current character is a vowel or a consonant.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1