Question: Write a C++ program that reads in text one character at a time and counts the number of occurrences of the following letters: 'a', 'g',

Write a C++ program that reads in text one character at a time and counts the number of occurrences of the following letters: 'a', 'g', 'm', 'f', 'k', and'j' in the text, and determines a total score for the text using a point based scheme. Both lower case and upper case letters should be counted together. When a period, ".", or exclamation mark, !", appears in the input text, the program prints how many of each letter above only, the total score of the text, and halts. Each letter being counted is assigned a score (similar to the board game Scrabble) as follows: 'a' (1 point), 'g' (2 points), 'm' (3 points), 'f' (4 points), 'k' (5 points"), and 'j' (8 points). All other characters have a score of - points. You will compute the total score of the input text by summing the number of occurrences of a letter above multiplied by its score. For example, if the input text is: she made a familiar attempt Just right., then the counts are 5 'a', 1 'g', 3 'm', 1 'f', 0 'k', and 1 ''j'. The total score for the phrase is 5 * 1 + 1 * 2 + 3 * 3 + 1 * 4 + 0 * 5 + 1 * 8 = 28

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!