Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with this C++ programming problem. Please note, this is C++, not Java language Write a program scrabble_game.cpp that reads in text one
I need help with this C++ programming problem. Please note, this is C++, not Java language Write a program scrabble_game.cpp that reads in text one character at a time and counts the number of occurrences of the following letters. 'e', "d, 'c, 'h, 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 textthe program prints how many of each letter above only, the total score of the text (see point assignments below), and halts. Each letter being counted is assigned a score (similar to the board game Scrabble) as follows: 'e' (1 point, 'd' (2 points), 'c' (3 points), 'h' (4 points), K' (5 points), and 'j (8 points)All other characters have a score of 0 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 worked hard to build the deck Just right., then the counts are 4e, 4 d, 1 c', 4 'h , 2 k', and 1 j. The total score for the phrase is 4 x 1 + 4 2 + 1 x 3 + 3 x 4 + 2 x 5 + 1 x 8 = 49 Here are the steps to help you code this problem. Program scrabble_game .cpp . a. To read in a single character, use cin to read a value of type char. b. Use a while loop to read and count the characters in the input. Read in a character, check that the input character is not the period, P, nor the exclamation mark, I 3, and then enter the while loop. C. Be sure to read in the next character at the end of the while loop. d. Lower case and upper case vowels should be counted together. Thus a text with three characters "e and four characters 'E' will have a total of 7 occurrences of e e. You can compute the total score using the point values of each letter we are counting as you count each letter in the while loop or after you have finished determining the counts, ie . after the while loop. f. Run your program on various input including boundary cases such as just a period, ", or just an exclamation mark, ! , as input
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started