Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i tried to modify this but it dont work were do you add these lines of code so t

ID: 3926570 • Letter: I

Question

i tried to modify this but it dont work

were do you add these lines of code so that it properly encodes messages containg both upper case and lower case letters, any non letters ,( spaces and punctuation marks shoud be left unchanged by the encoding

alphabet = aplhabet + aplhabet.toLlowerCase();

key = key + key.tolLowerCase();

<html>
<head>
<title> Substitution Cipher</title>

<script type="text/javascript">
function Encode()
// Assumes: the message to be encoded is in messageBox (all caps),
// the key for encoding is in keyBox (all caps)
// Results: the coded version of message is displayed in outputDiv
{
var message, key, alphabet, coded, i, ch, index;

message = document.getElementById('messageArea').value;
key = document.getElementById('keyBox').value;
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
coded = '';

i = 0;
while (i < message.length) {        // FOR AS MANY LETTERS AS THERE ARE
ch = message.charAt(i);            // ACCESS EACH LETTER IN MESSAGE
index = alphabet.indexOf(ch);        // FIND ITS POSITION IN ALPHABET
if (index == -1) {         // IF NOT A CAPITAL LETTER,
coded = coded + ch;        // THEN ADD IT UNCHANGED
}        // OTHERWISE,
else {         // ADD THE CORRESPONDING LETTER
coded = coded + key.charAt(index);    // IN THE KEY STRING
}
i = i + 1;
}

document.getElementById('outputDiv').innerHTML = coded;
}
</script>
</head>

<body>
<h2>Substitution Cipher</h2>
<p>
Key: <input type="text" id="keyBox" size=26
value="ZYXWVUTSRQPONMLKJIHGFEDCBA">
</p>
<p>
Enter your message below: <br>
<textarea id="messageArea" rows=8 cols=30></textarea> <br>
<input type="button" value="Encode the Message">
</p>
<hr>
<div id="outputDiv"></div>
</body>
</html>

Explanation / Answer

include #include #define MAXSIZE 1024 void encrypt(char*); void decrypt(char*); int menu(); int main(void) { char c, choice[2], s[MAXSIZE]; while(1) { menu(); gets(choice); if((choice[0]=='e')||(choice[0]=='E')) { puts("Input text to encrypt->"); gets(s); encrypt(s); } else if((choice[0]=='d')||(choice[0]=='D')) { puts("Input text to decrypt->"); gets(s); decrypt(s); } else break; } return 0; } void encrypt(char*str) { int n=0; char *p=str, q[MAXSIZE]; while(*p) { if(islower(*p)) { if((*p>='a')&&(*p='D')&&(*p