Question: ReverseCipher.java Write program ReverseCipher as follows: Class has 3 static methods: main, encrypt, and decrypt. Method encrypt takes two parameters, a String and an int.

ReverseCipher.java

Write program ReverseCipher as follows:

Class has 3 static methods: main, encrypt, and decrypt.

Method encrypt takes two parameters, a String and an int. It uses these to create and return a new

String. The method reads the original string object from back to front, adding the int value to each

character and casting the result to a char type. Each is then added to an empty string. The encrypted string is returned when complete.

Method decrypt takes two parameters, a String and an int. It uses these to create and return a new

String. The method reads the original string object from back to front, subtracting the int value to each

character and casting the result to a char type. Each is then added to an empty string. The decrypted string is returned when complete.

Method main will first prompt the user for a sentence and an integer. It will use these as arguments to

invoke method encrypt and display the returned string. Secondly, it will prompt for a sentence and an

integer, using both as arguments to invoke method decrypt and display the resulting string.

Example:

Enter a sentence to encrypt

Happy Thanksgiving

Enter an integer for encryption string

4

krmzmkworelX$}tteL

Enter a sentence to decrypt

krmzmkworelX$}tteL

Enter an integer for decryption string

4

Happy Thanksgiving

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!