Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will write a program using while loops (not for loops!) in this lab. You will receive no credit if you use for loops. Write

You will write a program using while loops (not for loops!) in this lab. You will receive no credit if you use for loops.

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: j, k, h, c, d, and e 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 (see point assignments below), and halts. Each letter being counted is assigned a score 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 1 + 4 2 + 1 3 + 3 4 + 2 5 + 1 8 = 49.

1. 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, ., nor the exclamation mark, !, 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, i.e. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Different types of Grading?

Answered: 1 week ago

Question

Explain the functions of financial management.

Answered: 1 week ago

Question

HOW MANY TOTAL WORLD WAR?

Answered: 1 week ago

Question

Discuss the scope of financial management.

Answered: 1 week ago

Question

state what is meant by the term performance management

Answered: 1 week ago