Design a program that reads several lines of text from the keyboard and prints a table indicating the number of occurrences of each letter of the alphabet (a to z) found in the text. If a non-alphabetic character is found, simply count how many were found and display that total at the end of the program.
Output should look similar to:
Letter Count
------ -------
a 6
b 24
…
z 0
There were 5 letters that were non-alphabetic.
I have got the program to put the phrase into the 2d array but I do not know how to be able to count each letter alone. Rite now it is working and is outputting the number of letters and number of chars. If anyone had any idea how to solve this problem please let me know i have the pseudocode already put in i just dont know how to do what i want to do. The only idea I have is to make another array, but even after that im still kind of confused. I think we are suppose to use pointers or ascii or maybe both. Thank you for everyones time to read this and provide any helpfull feedback.
int main( )
{
char textLine[numRows][lineSize] = {0};
char display[26][2] ={0};
int letterCount=0;
int charCount=0;
// prompt for input
cout << "Please insert data"<<endl;
// loop through the sentences
// read the input from the keyboard and convert to lowercase
for(int i=0; i < 3; i++)
{
cin.getline(&textLine[0], 80);
for(int j=0; textLine[j]!= '\0'; j++)
{
// check each letter to see if it is alphabetic
// determine which letter it is and increment letter count by 1
if( isalpha(textLine[j]))
{
letterCount++;
}
else
{
charCount++;
}
}
}
cout<<letterCount<<endl;
cout<<charCount<<endl;
// display a-z tally in a column
// display count of non alpha
return( 0 );
}