Question: Write a C++ program that assists in the solving of a cryptogram by reading text until the user types -D, then displays of the number

Write a C++ program that assists in the solving of a cryptogram by reading text until the user types -D, then displays of the number of occurrences of each letter.

Functional requirements:

Prompt the user to enter the text.

Read each character typed, incrementing a counter for corresponding letters. You need not keep track of non-alphabetic characters. Uppercase and lowercase characters should be treated identically (i.e. you need to maintain only 26 counters, with 'C' and 'c' both incrementing the same counter).

Sort the letters by number of occurrences in the text in descending order.

Print a list of letters and their number of occurrences, in descending order.

Implementation requirements:

You must use 2 arrays of 26 elements: the first is an array of characters, with each element initialized to the corresponding alphabetic character. The second is an array of longs, initialized to 0.

Your sorting algorithm must move corresponding elements in both arrays, based on the value stored in the counter array. That is, you must treat the two arrays as parallel arrays.

You must use one function to read the text and count the occurrences of each letter, a second to sort the parallel arrays, and a third to print the results. Appropriate use of const parameters is required.

Sample output:

miller: a.out 
Enter the cypher text (-D to end): Iqmmw Twpmv! 
 
M 3 
W 2 
I 1 
P 1 
Q 1 
T 1 
V 1 

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!