//UIUC CS125 SPRING 2016 MP. File: CaesarCipher.java, CS125 Project: Challenge3-TopSecret, Version: 2016-02-15T06:55:07-0600.622398463 /** * A program to search for to encrypt and decrypt lines of text. See * CaesarCipher.txt * Hints: line.charAt( int ) is useful. * You'll need loops, and conditions and variables * You'll need to read the Test cases to understand how your program should work. * Good Programming Hints: "DRY: Don't Repeat Yourself" * Try to make your program as short as possible. * TODO: add your netid to the line below * @author kosvick2 */ public class CaesarCipher { public static void main(String[] strings) { boolean done=true; boolean fun=true; while(done){ TextIO.putln("Please enter the shift value (between -25..-1 and 1..25)"); int shift = TextIO.getlnInt(); if(shift>=-25 && shift<=25 && shift!= 0) { TextIO.putln("Using shift value of " +shift); while(fun){ TextIO.putln("Please enter the source text (empty line to quit)"); String source = TextIO.getln(); if(source.length()==0){ TextIO.putln("Bye."); fun=false; done=false; } else { TextIO.putln("Source :"+source); TextIO.put("Processed:"); source = source.toUpperCase(); char[] decode = source.toCharArray(); for(int i=0; i= 'A') && (decode[i] <= 'Z') && (decode[i]!= ' ')){ decode[i] += shift; if((((decode[i]-'A')<0) || ((decode[i]-'A')<= 'Z')) && decode[i]!= ' ') { decode[i]= (char)((decode[i] - 'A' + 26)%26 + 'A'); } } TextIO.put(decode[i]); } } } } else { TextIO.putln(shift+ " is not a valid shift value."); } } } }