Lab 8: President’s Word Game C++

Project Goal

The goal of this program is to recreate the game from Lab 4 in C++ where the player guesses the more common word in a president ‘s Inaugural address. This time we will use George Washington’ first address. The program will show two words from the speech, and the user will guess which one is more common. Score is kept of their success or failure. Below are all (or almost all) inaugural addresses. You are are pick which one you wish to use.

In order to make the game more interesting, we want to rule out common words like “the”, “to”, “and”, etc. I have includes a file “StopWords.txt”. The program should ignore these words.

Learning Goals

  1. Reading from files
  2. Parsing lines into words
  3. Storing words in a vector of string
  4. Using a random number
  5. Using functions (including parameters and returning values)
  6. Checking for input errors

Example

Below is a sample game play:

Which word is more common:
either
instead
Enter 1, 2 or 0 if same:0
either occurs 1 times.
instead occurs 1 times.
You got it!
1/1
Go again? (y or n)y
Which word is more common:
nations
communities
Enter 1, 2 or 0 if same:1
nations occurs 1 times.
communities occurs 2 times.
Sorry!
1/2
Go again? (y or n)y
Which word is more common:
instead
habit
Enter 1, 2 or 0 if same:0
instead occurs 1 times.
habit occurs 1 times.
You got it!
2/3
Go again? (y or n)n

Method

You are to write a program to play this game. You are given a skeleton project to start from. You MUST complete and use all the functions in the starting code. You may add more functions if you need to. You should submit the final program when done.

Here is sample code showing how to generate a random integer: Code

Code to make a string lower case:

// String to lowercase
string toLower(string s) {
  for (int i = 0; i < s.size(); i++) { 
    s[i]=tolower(s[i]);
  }
  return s;
}Code language: JavaScript (javascript)


Starting code: Codeboard.io link

Turn in

Submit the project on onlineGDB and turn in the project link to Moodle. Be sure to include the standard information and the honor statement at the top of your program file. Any submission that is missing the Academic Integrity Statement will not be graded.

Grading

RequirementsGrading CommentsPointsScore
Fully functioning code that works exactly like game above60
Completion of all functions in the start code30
Fully commented code, with name, date, description, the honor statement, and comments on all functions.10
Total100

Edit

Scroll to Top