Marjorie enjoys Scrabble so much that she created her own scoring rules to make the game more challenging. This program computes scores based on her custom rules and determines the winner between Marjorie and John.
Table of Contents 📖
This program calculates the scores of two sequences of letters created by Marjorie and John, following these rules:
- 1 point for each vowel (
{'a', 'e', 'i', 'o', 'u'}
). - 2 points for each popular consonant (
{'t', 'n', 's', 'r', 'h'}
). - 3 points for every other letter.
- Whitespace characters are ignored.
The program then compares the scores and determines the winner.
- Two lines of lowercase letter sequences separated by whitespace, ending with a newline character.
- Whitespace does not count toward scoring.
- Input is read using the
getchar
function.
- If Marjorie’s sequence has a higher score, print:
Marjorie wins!
- If John’s sequence has a higher score, print:
John wins!
- If scores are tied, print:
Play again!
Enter the second sequence: hello world
Output: Marjorie wins!
Enter the second sequence: not this time marjorie
Output: Marjorie wins!
Enter the second sequence: cheap
Output: Play again!
Enter the second sequence: hi
Output: Play again!
-
The program must:
- Read the input sequences using
getchar
. - Ignore whitespace characters when calculating scores.
- Compute scores correctly based on the given rules.
- Compare scores and print the appropriate message.
- Read the input sequences using
1. Compile the Program:
2. Run the Program:
3. Input Required:
- Two lines of letter sequences.