Project 17
Project 17
You have just been hired by the CIA as a programmer in the encryption department. Your job is to
write a class called Crypto. One method, encrypt, will accept a String that represents the sentence to
be encrypted. It will return a String that is the sentence with all vs (big or small) replaced with
ag,r , all ms (big or small) with ssad, all gs (big or small) with jeb..w, and all bs (big or
small) with dug>?/.
The class contains another method, decrypt, that accepts a String that represents the sentence to be
decrypted. In this method, the reverse process described above is performed. It returns a String that
is the original sentence before encryption.
Use the following Tester class to ensure that your methods work.
import java.io.*;
import java.util.*;
public class Tester
{
public static void main(String args[])
{
Scanner kbReader = new Scanner(System.in);
System.out.print(Enter a sentence that is to be encrypted: )
String sntnc = kbReader.nextLine();
System.out.println(Original sentence = + sntnc);
Crypto myCryptObj = new Crypto();
String encryptdSntnc = myCryptObj.encrypt(sntnc);
System.out.println(Encrypted sentence = + encryptdSntnc);
String decryptdSntnc = myCryptOjb.decrypt(encryptdSntnc);
System.out.println(Decrypted sentence = + decryptdSntnc);
}
}
Test with this sentence: This is a very big morning. After running your program, your screen
should appear as follows:
Enter a sentence that is to be encrypted: This is a very big morning.
Original sentence = This is a very big morning.
Encrypted sentence = This is a ag,rery dug>?/ijeb..w ssadorninjeb..w.
Decrypted sentence = This is a very big morning.