Write a program which analyzes a text file by counting the number of times each of the 26 letters in the alphabet occurs. You must use an array to keep track of the how many times each letter is seen in the text file. Uppercase and lowercase letters should be counted together (for example, both ‘A’ and ‘a’ should count as an A). Any characters that are not letters should be ignored. You must prompt the user to enter the file name to be anaylzed. After the entire file has been read, print out the number of times each letter was seen. Recall that characters and integers are interchangeable via the ascii table conversion (see www.asciitable.com for a reference). This will be useful when deciding what the array index should be after reading a character from the file.

That is the problem and can anyone help me with this by giving me an outline of what I need to do. I am really confused about what to do for this problem.
Thank You!!

6 Years
Discussion Span
Last Post by SgtMe

What you need to do:

  • Make an array of length 26 to store each value of occurrences for each letter
  • Read through text file one byte at a time
  • Ignore spaces
  • If letter is <Uppercase> or <lowercase> add one to corresponding array value

Then obvs. set up a neat print statement to show how many times each letter occurs.
Arrays basics if you need to check anything:

Hope this helps :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.