Question: 1. Make a program that uses a map to store the count of all the words in a sentence, or paragraph. After you have processed

1. Make a program that uses a map to store the count of all the words in a sentence, or paragraph. After you have processed the paragraph, print out each word of the alphabet listed in the map and the number of times that word occurred in the paragraph. Ignore case and only count letters (no digits or punctuation or spaces.) You can use a file or you can make a long string as your input.

2. make program that uses a map to store the count of all the letters in a sentence, or paragraph. After you have processed the paragraph, print out each letter of the alphabet listed in the map and the number of times that letter occurred in the paragraph. Ignore case and only count letters (no digits or punctuation or spaces.) You can use a file or you can make a long string as your input.

Partial coding

#include

#include

#include

using namespace std;

int main()

{

char num;

char letter;

ifstream in("test.txt");

if (!in)

return 0;

//Make map called words

____________ words;

in>>num;

if(_____________) //is num letter?

________________// //convert num to upper case and store it in letter

while(!in.eof())

{

++words[letter];

____________// input another character

if(_____________) //is num letter?

________________// //convert num to upper case and store it in letter

}

in.close();

//Display the occurrences of letter in the document

for (____________________________________________) {

cout << ____________ << " : "

<< ___________________ << " times. ";

}

}

Run time output:

A : 128 times.

B : 20 times.

C : 85 times.

D : 69 times.

E : 217 times.

F : 43 times.

G : 53 times.

H : 57 times.

I : 102 times.

J : 1 times.

K : 5 times.

L : 85 times.

M : 41 times.

N : 132 times.

O : 106 times.

P : 54 times.

R : 122 times.

S : 149 times.

T : 152 times.

U : 73 times.

V : 15 times.

W : 39 times.

X : 4 times.

Y : 21 times.

Z : 1 times.

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!