Write a C++ program to do the following:
Read the attached file ("TextFile.txt") and the count the number of times each alphabetic letter is used. Do not count punctuation, whitespace, or numbers. Only count letters a-z. When counting, treat lower and upper case characters the same.
Use the attached CPP program as a guide to manage the counting. Use the structure and array provided to maintain counts. See examples in the program.
When the all processing is completed, display the total for all letter counts.
Example Output Below.: This numbers below are not intended to be accurate. No special formatting required but should be readable.
A: 103
B: 15
C: 22
... // remaining letters
Z: 4
cpp code:
#include "stdafx.h"
#include <iostream>
using namespace std;
struct LetterCount
{
char letter;
int count;
};
// declare an array of structure
const int MAXLETTERS = 26;
LetterCount myLetterCount[MAXLETTERS];
int main()
{
// initialize - MOVE THIS TO A METHOD
for (int idx = 0; idx<MAXLETTERS; idx++) {
myLetterCount[idx].count = 0;
myLetterCount[idx].letter = 'a' + idx; // this will load a-z
}
// search and inc EXAMPLE
char letterToFind = 'a';
for (int idx = 0; idx<MAXLETTERS; idx++) {
if (myLetterCount[idx].letter == letterToFind) {
// inc the count here
}
}
// showLetterCounts - MOVE THIS TO A METHOD
for (int idx = 0; idx<MAXLETTERS; idx++) {
cout << myLetterCount[idx].letter << " " << myLetterCount[idx].count << endl;
}
}
TextFile:
"Count On Me"
I'll sail the world to find you
If you ever find yourself lost in the dark and you can't see
I'll be the light to guide you
We find out what we're made of
When we are called to help our friends in need
You can count on me
Like 1, 2, 3
I'll be there
And I know when I need it
I can count on you
Like 4, 3, 2
You'll be there
'Cause that's what friends are supposed to do
If you're tossin' and you're turnin'
And you just can't fall asleep
I'll sing a song beside you
And if you ever forget how much you really mean to me
Every day I will remind you
We find out what we're made of
When we are called to help our friends in need
You can count on me
Like 1, 2, 3
I'll be there
And I know when I need it
I can count on you
Like 4, 3, 2
You'll be there
'Cause that's what friends are supposed to do
You'll always have my shoulder when you cry
I'll never let go, never say goodbye
You know
You can count on me
Like 1, 2, 3
I'll be there
And I know when I need it
I can count on you
Like 4, 3, 2
And you'll be there
'Cause that's what friends are supposed to do
You can count on me 'cause I can count on you
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- Write a C++ program that reads a list of numbers from a file into an array, then uses that array to find the average of all the numbers, the average of the positive and negative numbers (0 is neither positive nor negative!), and the largest number. The point is to be able to store data in an array and do things with it Your program must contain at least the following four functions... read_list() This function will take as input parameters an array of integers and a string filename. It will open that file and read in numbers, storing them in the array, stopping at the end of the file. Remember that there are tricky issues with extra whitespace at the end of the file. You can assume the file contains only integers. The function will return the number of numbers that were read in.Note: In versions of Visual C++ pre-2010, when using the open function with a string argument, you must call the c_str() function on the string variable, such as:my_input_stream.open( filename.c_str() ) 2.…arrow_forwardWrite a C program using arrays to input 10 integer numbers, store them in an array and update the array elements by Increment to 3. Print the updated array elements in the reverse order. Note: Use Arrays and Loops Use suitable names and datatypes for your variables Hint: Refer the Screenshot Save the screen shot of the output and the program on the Desktop folder. Output: Please Enter 5 Integers : 101 102 103 104 105 The Updated Array Is 108 107 106 105 104 Program finished with exit code 0 Press ENTER to exit console.] A- B I Moviearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education