Skip to content

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.

Notifications You must be signed in to change notification settings

C-Coding-Assignments/Scrabble

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Scrabble-Like Game Scorer 🎲

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 📖

Task 🛠️

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.


Input and Output 🖥️

Input

  • 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.

Output

  • 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!

Examples 📋

Example #1

Enter the first sequence: not this time john
Enter the second sequence: hello world
Output: Marjorie wins!

Example #2

Enter the first sequence: hello world
Enter the second sequence: not this time marjorie
Output: Marjorie wins!

Example #3

Enter the first sequence: peach
Enter the second sequence: cheap
Output: Play again!

Example #4

Enter the first sequence: no
Enter the second sequence: hi
Output: Play again!

Requirements ✔️

  1. 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.

Usage 🚀

1. Compile the Program:

gcc -o scrabble_scoring scrabble_scoring.c

2. Run the Program:

./scrabble_scoring

3. Input Required:

  • Two lines of letter sequences.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages