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

Background: 1. Consider the following sentence: Java is wonderful, and Boy, do I

ID: 3621527 • Letter: B

Question

Background:
1. Consider the following sentence:
Java is wonderful, and Boy, do I Enjoy writing PROGRAMS!
We could "encrypt" this sentence by shifting all alpha characters 2 letters to the right.
Letters that would be moved beyond 'z' or 'Z' could be wrapped around to the beginning
of the alphabet again. All non-alpha characters should be left as is. If we did this, we
would get:
Lcxc ku yqpfgthwn, cpf Dqa, fo K Gplqa ytkskpi RTQITCOU!
2. If we took a phrase, and repeated the process mentioned above 13 times, what would
we get? Well, we should get the original phrase, because 2 x 13 = 26, and the letters
would rotate to their original position.
Assignment:
1. Write a program that prompts the user to input a word, phrase, or sentence.
2. Your program should then "encrypt" the input by using the technique described
above. The process should be done 13 times, with each new expression printed to the
screen. The last expression should match the user's input.
3. Make sure that you only "encrypt" alpha characters. Numbers, punctuation marks,
etc. should be left as they originally appear in the user's input.

1. Make sure that your output looks like the following  sample run output. User
input is shown in bold:

 

___________________________________________________________________

 

 

Welcome to Encrypt.java.

Please enter a word, phrase, or sentence.-> Java is wonderful, and Boy, do I Enjoy writing PROGRAMS!

 

 

Encryption 1:

 

Lcxc ku yqpfgthwn, cpf Dqa, fq K Gplqa ytkskpi RTQITCOU!

 

 

Encryption 2:

 

Neze mw asrhivjyp, erh Fsc, hs M Irnsc avmumrk TVSKVEQW!

 

 

Encryption 3:

 

Pgbg oy cutjkxlar, gtj Hue, ju O Ktpue cxowotm VXUMXGSY!

 

Encryption 4:

 

Ridi qa ewvlmznct, ivl Jwg, lw Q Mvrwg ezqyqvo XZWOZIUA!

 

 

Encryption 5:

 

 

Tkfk sc gyxnobpev, kxn Lyi, ny S Oxtyi gbiasxq ZBYQBKWC!

 

 

Encryption 6:

 

 

Vmhm ue iazpqdrgx, mzp Nak, pa U Qzvak idkcuzs BDASDMYE!

 

 

Encryption 7:

 

 

Xojo wg kcbrsftiz, obr Pcm, rc W Sbxcm kfmewbu DFCUFOAG!

 

Encryption 8:

 

Zqlq yi medtuhvkb, qdt Reo, te Y Udzeo mhogydw FHEWHQCI!

 

 

Encryption 9:

 

Bsns ak ogfvwjxmd, sfv Tgq, vg A Wfbgq ojqiafy HJGYJSEK!

 

 

Encryption 10:

 

 

Dupu cm qihxylzof, uhx Vis, xi C Yhdis qlskcha JLIALUGM!

 

 

Encryption 11:

 

 

Fwrw eo skjzanbqh, wjz Xku, zk E Ajfku inumejc LNKCNWIO!

 

Encryption 12:

 

 

Hyty gq umlbcpdsj, ylb Zmw, bm G Clhmw kpwogle NPMEPYKQ!

 

Encryption 13:

 

Java is wonderful, and Boy, do I Enjoy writing PROGRAMS!

 

____________________________________________________________________

Explanation / Answer

please rate - thanks

import java.util.*;
public class encrypt
{
public static void main(String[] args)
{String input, encryp,decrypt;
char code,ch;
int i,j,key=2,characters;
Scanner in=new Scanner(System.in);
System.out.println("Welcome to Encrypt.java.");
System.out.print("Please enter a word, phrase, or sentence.-> ");
input=in.nextLine();
for(j=0;j<13;j++)
{
encryp="";
System.out.print("encrypted "+(j+1)+": ");
for(i=0;i<input.length();i++)
     {code='a';
       if(!Character.isLetter(input.charAt(i)))
          ch=input.charAt(i);
        else
           {if(Character.isUpperCase(input.charAt(i)))
              code='A';
            ch=(char)((input.charAt(i)-code+key)%26+code);
           }
       
      encryp+=ch;     
     }
    System.out.println(encryp);
    input=encryp;
   
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote