Question: Program 6 Basic: Brutus Goal: Remember how last program it output all possibilities for the Caesar shift and we , the humans, had to read

Program 6 Basic: Brutus
Goal:
Remember how last program it output all possibilities for the Caesar shift and we, the humans, had to
read through to find the one in English? In this program, youre going to extend your Caesar program so
that it can determine which shift is the English text!
How can a computer know English?
The simple answer is it doesnt. However, we can provide it a list of words and have the computer check
to see if a word is in the list. Then if enough words are found, the computer can say yeah, thats
probably the English one.
The simplest way to do this (the way well do it for this program) is to make an array of words found in
the words.txt file...
1) Read a line of the file.
2) Get rid of
and any non-letter characters.
3) Append it to an array (called dictionary or something similar).
Then to determine if a shifted line is in English...
1) Split the shifted line by its spaces so you have an array of words.
2) For each word in the array, see if its in the dictionary array. If it is, increase a count by 1.
a. HINT: if word in dictionary: will do that for you!
3) After youve checked every word in the shifted line, see if your count is greater than or equal to
40% of the number of words in the shifted line.
a. If it is, output that line and which shift it is.
b. Else, do the next shift then determine if that one is in English.
Specifications:
Read the file one line at a time.
Output the original line.
Apply every possible Caesar shift to the input line.
o NOTE: You are only shifting alphabetic characters (letters) punctuation and spaces
should remain intact!
For each shift, determine if its in English. Output only the English shift!
o NOTE: You may be killing punctuation to determine if a word is in the dictionary, but
your output must have the punctuation intact!
Time the whole thing like you did last program.
Constraints:
You must have at least one subroutine that applies a single shift to the line. You may include
additional subroutines.
Your output must show the correct shift as instructed.
Output is worded like the sample below.
You must comment your source code appropriately, include an informative header at the top,
and use good coding style.
You must use meaningful variable names.
Hints:
Fix all bugs from the last program before you begin if Caesar didnt work, Brutus wont!
Make a smaller file from the one I gave you for testing purposes, like 5 or 6 lines. Itll save you
time as you try to develop your algorithm. Just remember: Before you submit your code, make
sure it works for the original file!
Yes, all letters in the input file are CAPS.
Since both the words for the dictionary and the words from the shift may have non-letter
characters, youll probably want one subroutine to get rid of punctuation!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!