Question: C++ Programming: Write a program that will read a line of text and output a list of all the letters that occur in the text

C++ Programming: Write a program that will read a line of text and output a list of all the letters that occur in the text together with the number of times each letter occurs in the line. End the line with a period that serves as a sentinel value. The letters should be listed in the following order: the most frequently occurring letter, the next most frequently occurring letter, and so forth. Case should be ignored ('a' should be treated the same as 'A'). If two or more letters have same frequency, print them in lexicographical order. The program will prompt the user to enter the lines of text in the terminal. The text line may contain any English letter and zero or more whitespace characters (spaces and tabs only).

The program should print a string of text to the terminal before getting each line of input from the user. A session should look like one of the following examples (including whitespace and formatting), with a possibly numbers and letters in the output:

Enter text: do be do bo. Frequencies: o 3 b 2 d 2 e 1 
Enter text: aaaaaaaaaabbbbbbbbbbcccccccccca. Frequencies: a 11 b 10 c 10 

The string printed by the program should include a newline at the end, but no other trailing whitespace (whitespace at the end of the line).

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 Databases Questions!