Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class part3 {
- public static void main(String[] args) {
- String decryptKey = "QWERTYUIOPASDFGHJKLZXCVBNM";
- String decryptKey2 = "qwertyuiopasdfghjklzxcvbnm";
- String msg = "Hn fig vky dckm ephl, fig pkwc oie cwcdfephyo bidrhyo.\n" +
- "Bcss miyc hymccm!\n" +
- "Figd jdiodkz pkm lgvvcllngssf mcvdfjecm epc zcllkoc.\n";
- int i;
- int index = 0;
- int index2 = 0;
- for (i = 0; i < msg.length(); i++) {
- char c = msg.charAt(i);
- if (Character.isUpperCase(c)) {
- char charDecrypt = Character.toUpperCase(c);
- index = charDecrypt - 'A';
- System.out.print(decryptKey.charAt(index));
- }
- else if (Character.isLowerCase(c) ) {
- char charDecrypt2 = Character.toLowerCase(c);
- index2 = charDecrypt2 - 'a';
- System.out.print(decryptKey2.charAt(index2));
- }
- else {
- System.out.print(c);
- }
- }
- }
- }
- /* Output: If you can read this, you have got everything working.
- Well done indeed!
- /* Your program had successfully decrypted the message.
Add Comment
Please, Sign In to add comment