Question: Write a program that, given the name of a text file, reads that file and counts the number of occurrences of each alphabetic letter in

Write a program that, given the name of a text file, reads that file and counts the number
of occurrences of each alphabetic letter in the file. Your program should print out the
occurrences result on the screen and ask the user to enter a file name to store the result.
Your program should use a vector of length 26 to count the occurrences of the 26
alphabet letters, and treat upper and lower-case instances of a letter as the same letter.
Hint:
1. Use vector occurrences(26);
2. Use tolower(letter) function if the letter is uppercase (slide 24 of the lecture note
using classes);
3. Use letter a as the index for the vector occurrences, i.e., occurrences [letter-a]++.
Therefore, occurrences[0] expresses the occurrences of a, occurrences[1]b,...
Example: In a file that said Hello World, the vector occurrence would look like:
[0,0,01,1,0,0,1,0,0,0,3,0,0,2,0,0,1,0,0,0,0,1,0,0,0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!