Sentence Cipher

Other

 This assignment will consist of a single class, with all code in the main() method. Call your class SentenceCipher (that is, the source code will be in a file called SentenceCipher.java). If you choose to use an IDE other than DrJava, ensure that your program is not defined in a package (there should be no package statement at the top of the file).

When your assignment is complete, a user running your program will be prompted to enter the shared ‘source’ text, then asked if they want to encrypt or decrypt a message. The source text may contain any mixture of characters, including punctuation and spaces. Before continuing, the source text must be converted to all lower case.

After receiving the source text from the user, they will be asked to choose one of two options:

  1. Encrypt a message
    • The user is prompted to enter a word to be encrypted (this word is converted to lower case).
    • The program finds the position in the source text of the first occurrence of each character from the word (or -1 if the character cannot be found) and creates a new String containing those positions, separated by spaces and ending with -2.
    • The program displays the list of positions, preceded by the text “Result: ”.

1.  On a separate line, the program outputs the amount of information loss, which is charactersnotfoundwordlength×100

    • This should be preceded by “Information loss (%): ”.
  1. Decrypt a message
    • The user is prompted to enter a list of positions, separated by spaces and ending with -2 (to indicate the end of the word).
    • As long as the next position is not -2, the program reconstructs the word one character at a time:
      • if the position is within the bounds of the source text then the character at that position is added to the word;
      • if the position is -1 then an underscore (_) is appended to the string, indicating an unrecoverable character; and
      • if the position is less than -1 or beyond the end of the source text then an exclamation mark (!) is appended to the word.
    • If there were any invalid positions (less than -1 or beyond the end of the source text) then the program should print a message indicating how many. The number should be followed by the text ” invalid position(s)“. The message should not be displayed at all if there were no invalid positions.
    • The program outputs the recovered message, preceded by the text “Result: ”
    • On a separate line, the program outputs the amount of information loss, which is charactersnotfoundwordlength×100, , where the number of characters not found includes both positions of -1 and invalid positions. This should be preceded by “Information loss (%): ”.

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational