Monday, October 29, 2012

Java Exercise #37: Count Each Letter of String

The problem is to write a program that prompts the user to enter a string and counts the number of occurrences of each letter of the string regardless of the case.

The following are the steps involved.

  1. Convert the String to lowercase
  2. Create an array of size 26 for storing the count of each letter
  3. Increment the count for each letter after confirming that each letter is an alphabet

Exercise: Write a program that implements the above to count each letter of a string


Enter string: ababax
a appears 3 times
b appears 2 times
x appears 1 time



Download Code: Count Each Letter

No comments:

Post a Comment