The New York Times article The Two Codes Your Kids Need to Know (2/12/2019, by Thomas Friedman) describes how the leaders of the College Board (makers of AP exams) asked themselves a radical question:
Of all the skills and knowledge that we test young people for that we know are correlated with success in college and in life, which is the most important? Their answer: the ability to master “two codes” — computer science and the U.S. Constitution.
The U.S. Constitution empowers you to "not only navigate society and its institutions but also to improve and shape them", and computer science allows you to "shape the world around you, and not just be shaped by it." In this assignment we will use computer science to explore the Constitution and the Bill of Rights, using the version included at the bottom of this page. Running the program looks like the following:
User input for choosing menu options can be upper or lower case.
Word search is also case insensitive. Thus a search for "five years" would match with "five YEARS".
Search should work for either a single word or for a search phrase. Options you may consider using include C++ vectors and the C++ string type.
Note that the following menu options:
P Display previous text F Display following text A Display all occurrences of found word
are not originally shown, and only show up after you have already searched for a word or phrase.
Only non-blank lines should be numbered and used when displaying previous and following text. There may zero or multiple empty lines between non-blank lines.
When displaying all occurrences of a found word or phrase, subsequent request for the previous or following text will be relative to the initial first find of that word or phrase.
(5 points) Implements exiting program.
Test input: x
(5 points) Implements searching for a word and displaying the first occurrence of enclosing text, handles lower-case menu input, and shows new menu option after word is found. Test input:
w re-examined
x
(5 points) Implements searching for a phrase and displaying the first occurrence of enclosing text, handles upper-case menu input, and shows new menu option after phrase is found. Test input:
W intoxicating liquors
x
(5 points) Implements displaying previous lines, up until the first line, upon which the following message is given: "There is no previous file contents." Test input: W perfect
p p x
(5 points) Implements displaying following lines, up until the last line, upon which the following message is given: "There is no following file contents." Test input: W intervened
p p f f f x
(10 points) Implements displaying all occurrences of some word or phrase. Test input:
w impeach
a x
(10 points) Hidden test 1
(10 points) Hidden test 2
There is no starter code for this project. You have enough experience and enough examples to do this on your own. Work on this in Zybooks at section 7.21