Java Cipher Program issue -
i posted program yesterday , i'm stuck. can't figure out why i'm getting errors getting, i've read bunch of stuff, frankly struggling java in general. appreciated...code , errors follow...
/* jursekgregchapter12t.java greg jursek program encrypt entered text user input shift value , decrypt text in same manner. */ import java.lang.*; import java.util.*; public class jursekgregchapter12t { public static void main(string[] args) { scanner stdin = new scanner(system.in); string encrypttext; // text encrypted string decrypttext; // text decrypted int shiftvalue; // number of spaces shifted via user input // user enters plain text encryption system.out.print("please enter text encrypt"); encrypttext = stdin.next(); // user enters shift value system.out.println("please enter shift value"); shiftvalue = stdin.nextint(); // system prints encrypted text string encryptedtext = encrypt(encrypttext , shiftvalue); // text has been encrypted system.out.println(encryptedtext); // user enters text decryption system.out.print("please enter text decrypt"); decrypttext = stdin.next(); // user enters shift value system.out.println("please enter shift value"); shiftvalue = stdin.nextint(); // system prints decrypted text string decryptedtext = decrypt(decrypttext , shiftvalue); // text has been decrypted system.out.println(decryptedtext); } // end main // shift , character manipulation public static string shift(string enteredtext, int shiftvalue) { string convertedtext = ""; for(int = 0; i< enteredtext.length(); i++) { char lowercase = enteredtext.charat(i); //convert upper case letters char lowercase = character.touppercase(lowercase); int charnumber = upperletter; //shift letters , wrap text int rotateletters = (charnumber + shiftvalue) % 26; char shiftletters = (char)rotateshift; //populate new string of characters convertedtext += shiftletters; } return convertedtext; } // encryption code public static string encrypt(string enteredtext, int shiftvalue) { string encryptedstring = rotate(enteredtext , shiftvalue); return encryptedstring; } // decryption code public static string decrypt(string enteredtext, int shiftvalue) { int negativeshiftvalue = (-1) * (shiftvalue); string decryptedstring = rotate(enteredtext , negativeshiftvalue); return decryptedstring; } } //end class jursekgregchapter12t
errors:
/users/greg/documents/programming/java/jursekgregchapter12t.java:59: error: variable lowercase defined in method shift(string,int) char lowercase = character.touppercase(lowercase); ^ /users/greg/documents/programming/java/jursekgregchapter12t.java:60: error: cannot find symbol int charnumber = upperletter; ^ symbol: variable upperletter location: class jursekgregchapter12t /users/greg/documents/programming/java/jursekgregchapter12t.java:64: error: cannot find symbol char shiftletters = (char)rotateshift; ^ symbol: variable rotateshift location: class jursekgregchapter12t /users/greg/documents/programming/java/jursekgregchapter12t.java:75: error: cannot find symbol string encryptedstring = rotate(enteredtext , shiftvalue); ^ symbol: method rotate(string,int) location: class jursekgregchapter12t /users/greg/documents/programming/java/jursekgregchapter12t.java:83: error: cannot find symbol string decryptedstring = rotate(enteredtext , negativeshiftvalue); ^ symbol: method rotate(string,int) location: class jursekgregchapter12t 5 errors [finished in 2.7s exit code 1]
Comments
Post a Comment