
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
How to write a Pseudocode for this project?
Project 1: Caesar Cipher
Assignment Overview
In this assignment, we are going to implement a simple encoding and decoding of text. As a result of working on this project, you will gain more experience with the use of:
1. string
2. if statement
3. for loop and while loop
Background
A rotation cipher is one of the simplest, plain-text ciphers, known since at least the time of Julius
Caesar. It takes in a plain-text string, and translates it into a new string based on a rotation of the alphabet being used. The basis is a “rotation”, a re-sequencing of an alphabet. Consider the following example. Consider the alphabet being a single string consisting of the lower case English letters as below (shown with each letter’s associated index):
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
211
22
23
24
25
Then a rotation of 3 means that the first three letters of the alphabet are moved to the end of the sequence, while the other letters move up, as shown below. Notice that the movement is done one letter at a time.
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
23
24
25
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
A cipher is created by using the rotated alphabet to replace each letter in the original string with its
rotated equivalent letter. Using the example above, the word “this” is translated as follows:
• the ‘t’ is found at index 19 in the alphabet. The letter in the rotated alphabet is ‘w’.
• the ‘h’ is found at index 7, the rotated letter is ‘k’
• the ‘i’ is found at index 8, the rotated letter is ‘l’
• the ‘s’ is found at index 18, the rotated letter is ‘v’
Thus the string ‘this’ becomes the string ‘wklv’ using a rotation of 3.
Project Description / Specification
1) The program should prompt the user for one of three commands:
a)‘e’ to encode a string
b)‘d’ to decode a string
c)‘q’ to quit
Any other command should raise an error and reprompt.
2) If the command is encode, then the program prompts for a string to encode and a rotation
integer in the range of 1-25. The program then returns the encoded string.
a) Important, the program should not encode any letter that is not in the lower case alphabet. Those letters should simply be passed through to the encoded string
3) If the command is decode, then the program should prompt for a string to decode and a plain-text word that appears in the text (decoded string). The output should be the rotation needed to decode the string and the decoded string (text).
a) If the program receives one word that belongs in the decoded string, then the program searches for a rotation that finds that word in the decoded string. That is the proper rotation. Finding that rotation is the goal of the program.
b) If no rotation is found, then the program should indicate this fact.
4) If the command is quit, then the program ends and prints a nice exit message.
Deliverables
You must use turn in the file proj01.py – this is your source code solution; be sure to include your names, the project number and comments describing your code.
Notes and Hints:
You should start with this program, as with all programs, by breaking the program down into parts.
Here is some of that breakdown to help you
Your program should continuously prompt for a command. Can you write a loop that prompts for one of the three commands ‘d’, ‘e’ or ‘q’ and reports an error if it is not one of those commands?
A rotation of an alphabet. Start with a string that consists of the letters a-z in a single string. How can you create a new string of the same length that has a particular rotation? Think of the string slicing operators. What do you need to do to the original string to create a new string of the indicated rotation? What pieces can you concatenate together to make the rotated alphabet?
Given two strings, one the lower-case alphabet and one a rotated alphabet, how can you encode a given string? You need to go through each letter of the string to encode, find it in the regular alphabet, remember its location/index in that alphabet, then find the letter in the rotated alphabet at the same index. The python method indexis helpful here. It indicates the location of a letter. Thus ‘abcdef’.index(‘c’) should return the value 2, the index of the letter ‘c’. ‘abcdef’.index(‘bcd’) returns 1, where the beginning of the sequence ‘bcd’ occurs. ‘xyz’.index(‘c’) returns - 1, as ‘c’ does not occur in the string.
When encoding a string, you should check to see if the letter from the original string is in the alphabet. You may use the in operator. ‘a’ in ‘abcde’ returns True. ‘.’ in ‘abcde’ returns False.
Decoding is probably the most complicated, best addressed last. You are given a string to decode and a word that occurs in the string. For example, the string ‘this is a test’, when encoded with a rotation of 3, becomes ‘wklv lvd whvw’. When decoding, you provide the encoded string and the word ‘test’.
Part 1, can you undo the encoding process if you know the rotation? Here, we find the letter in the rotated alphabet and decode it to the letter in the normal alphabet (the opposite for what we did for encoding).
Part 2, you need to perform Part 1 above on rotations of 1 to 25. If the decoded string contains (remember the in operator) the target string provided (‘test’), this must be the correct decoding. Remember the rotation and output the rotation and the decoded string.
1. If you go through 1-25 rotations and the target string is not found, then there is no decoding of the string possible. Report that.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

Knowledge Booster
Similar questions
- Given positive integer numInsects, write a while loop that prints, then doubles, numInsects each iteration. Print values = 1arrow_forwardPlease help me with this Create an unbreakable encryption and decryption program using java. Then create a GUI txt file. But use your own ideas. More information is down belowarrow_forwardJava Your program must read a file called personin.txt. Each line of the file will be a person's name, the time they arrived at the professor's office, and the amount of time they want to meet with the professor. These entries will be sorted by the time the person arrived. Your program must then print out a schedule for the day, printing each person's arrival, and printing when each person goes in to meet with the professor. You need to print the events in order of the time they happen. In other words, your output will be sorted by the arrival times and the times the person goes into the professor's office. In your output you need to print out a schedule. In the schedule, new students go to the end of the line. Whenever the professor is free, the professor will either meet with the first person in line, or meet with the first person in line if nobody is waiting. Assume no two people arrive at the same time. You should solve this problem using a stack and a queue. You can only…arrow_forward
- Using Python Spark Read each text files that are provided and convert each words in the file to lower case. (I cannot upload the text files so if you find a folder online with 15 text documents that would work) Create a list with words from each text files. Remove stop words from each list and get the final list of words for each text files. (The list of stop words are provided in stopwords.txt)arrow_forwardWrite a while loop that asks people why they like programming. Each time someone enters a reason, add their reason to a file that stores all the responses.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY