[SOLVED] Assignment 5 Arrays/ Strings

30 $

Assignment 5Arrays/ Strings

Grading: EVERY assignment in this course is graded by demoing your work for 10minutes with a TA. You are required to meet with a TA within one week after the duedate to demo. You are penalized for missing a scheduled appointment. In either case,if you submit late within 1 day (24 hours) of the deadline, you lose 10 points. if yousubmit late within 3 days of the deadline, then you lose 25 points. Your job is toconvince the TA that your program works correctly, i.e. show your TA how touse/break your program.

1. You will create a program to encrypt messages.(50 points)You will create a program that uses Fractionated Morse code to encrypt and decryptmessages.Don’t Panic!You need know nothing about Morse code.

First you will read in a CDstring with the message to encode.Use this table to create anarray of characters or string with each dot or dash as a separate character and Xs to indicatespaces.X between characters and XX between words.

A
*
D

N
D
*

B
D
*
*
*

O
D
D
D

C
D
*
D
*

P
*
D
D
*
D
D
*
*

Q
D
D
*
D
E
*

R
*
D
*

F
*
*
D
*

S
*
*
*

G
D
D
*

T
D

H
*
*
*
*

U
*
*
D

I
*
*

V
*
*
*
D
J
*
D
D
D

W
*
D
D

K
D
*
D

X
D
*
*
D
L
*
D
*
*

Y
D
*
D
D
M
D
D

Z
D
D
*

Table 1:Morse code equivalents

You also get a keyword or phrase from the user.Create a function to removeduplicate letters.So beavers becomes beavrs.You will use it to fill in the firstcolumn of this table with the remainder of the alphabet filled in after the keyword:
*********DDDDDDDDDXXXXXXX
***DDDXXX***DDDXXX***DDDXX
*DX*DX*DX*DX*DX*DX*DX*DX*D
Table 2:Encryption replacements

B
E
A
V
R
S
C
D
F
G
H
I
J
K
L
M
N
O
P
Q
T
U
W
X
Y
Z
X

To encode “hello world” you first get the Morse code from table 1:
****X*X*D**X*D**XDDDXX*DDXDDDX*D*X*D**XD**XX

Divide (fractionate) them into groups of 3:

Then get the ciphertext for each column from table 2, as shown in red.If the last group only hasXs then you can ignore it.
So the encrypted message is BCQAV DLPNL HQAG.In telegraphic transmission we group them in5 letter groups.

DESIGN CONSIDERATIONS
First, read the instructions carefully.

What do you need to do?You will read in a string of characters, including spaces.You mustreplace each character with its equivalent Morse code symbols (i.e. dots and dashes).You willuse the 26Drow table 1 to do that.Remember to put in an X between letters and XX betweenwords.You will take these symbols in groups of 3 to reference table 2.Each 3 symbols will bereplaced by the letter indicated.Once you’ve done that then you display the resulting ciphertextto the screen.

The tables display individual characters for clarity of understanding.You may simplify yourdesign by treating them as strings such as this for the first row of table 1:

This will create a 26 row by 2Dcolumn table.Create function that takes a single input character,looks up the Morse equivalent from the table and returns that string.Concatenate it onto theintermediate string.

You can do something similar to table 2.As you would be searching it by the string of symbolsyou might want the first row of that 26Drow table to look like this:

You will pull off 3 characters at a time from the intermediate string and look up the outputciphertext letter to concatenate to the output string.Write a function to take the 3Dcharacterstring and return the ciphertext letter to concatenate to the output string.Remember you alsoneed a function to take the key word or phrase entered by the user and strip duplicate lettersbefore filling in table 2.

You will have a function to print the output ciphertext string.It will have a single parameter,which is the string.As it prints remember every sixth letter will be a blank space character togive the 5Dletter groups.The output will be all uppercase letters.
You will use CDStrings so review the string library.You will need to compare strings and stick 2
B
C
Q
A
V
D
L
Q
N
L
V
Q
A
G

*
*
x
*
*
*
D
x
D
D
*
x
*
D
x
*
X
*
*
D
x
D
*
x
D
D
*
*
*
x
*
*
D
x
*
D
x
D
D
x
*
D
x
*

A
*D
***
B

strings together.

HINT: Make your program case insensitive.Whichever way you convert the input create afunction so you only need to write the code once.If you did this on a previous assignment thenyou do not need to write it again!

2. You will modify your program to decrypt messages.(15 points)To decrypt a message you reverse the process.You substitute for each ciphertext letter using thesecond table then decipher the symbols using the first table.
This will be similar using a lot of table lookup!You will convert each input ciphertext letter to the3Dcharacter groups from table 2.Write a function that does the lookup.The input can be oneletter at a time or the input string.HINT: After you convert each ciphertext letter you are finished with it!You can just remove itfrom the input string.Or you can just keep track of which ciphertext character is next in theinput.
You will now have a string that contains dots, dashes, and Xs.Create a function to read the string. Save each character until you get to an X.Take the symbols and look up the plaintext letter intable 1.Add it to the output string.Skip or delete the X.Repeat.After you skip or delete the X ifthe next character is another X add a blank space to the output string and skip or delete that X.

When you get to the end of the ciphertext string you just need to print it to the user.

You will never enter or see the Morse code!You can use whatever symbols in place of dots anddashes you want internally.

KEEP IT SIMPLE:Morse cod includes numbers and some punctuation.You will not use them! Use short sentences for testing.Incremental development.Write your program and debug without a keyword.Just use a straightalphabet with table 2.Once you have the bugs worked out, save a copy of your program, then addthe functions to read the keyword and write it to the table.When you do that how will you knowif you already used a letter?

3. You will modify your program to increase the security.(5 points)If you look at the encryption table, table 2, low frequency letters at the end of the alphabet tend tobe in the same place, which can make the security a tad bit weaker.How can you avoid this?

You can have the keyword start in some column other than the first column.Such as this:
This adds an offset to the keyword so you would also need to prompt for an offset of 1 to 25.Whydon’t you need an offset of 26?

W
X
Y
Z
B
E
A
V
R
S
C
D
F
G
H
I
J
K
L
M
N
O
P
Q
T
U
(10 pts) Program Style/CommentsIn your implementation, make sure that you include a program header in your program, inaddition to proper indentation/spacing and other comments! Make sure you review thestyle guidelines for this class, and follow them, i.e. don’t align everything on the left or puteverything on one line!

(10 pts) Design
Develop and document your design.Think about testing!Identify decision points whereyour flow of control may change (indicating a different logic path).If possible show howyour design changed as you solved problems.

(10 pts) Testing Your test plan must cover all the logic paths through your program.Indicate which itemsfailed the test and how you tested again. You will provide a test plan.Remember the testplan should be a table:
Input
Expected Output
Actual Output
Comments/explanation
You will be graded on how thorough your test plan is and how you used it to find and fixproblems.
HINT:Your testing must include all rows and columns of both tables!And must includeusing different keywords.

HINT:Use functions to decompose your design and help make it readable.Severalfunctions are already specified.Use others where appropriate.Remember that functionsshould be specific to a single task, which means they should be no more than around 15lines of code.They can help with incremental development.

Electronically submit your C++ program and pdf, by the assignment due date, usingTEACH.
**NOTE: The easiest way to upload your program from ENGR to TEACH is to map a networkdrive to your home directory on ENGR. Mac or Windows,

If you are doing this off campus, pay attention to the offScampus directions!!!!

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Assignment 5 Arrays/ Strings
30 $