0

I'm working on a simple encryption/ decryption program for class. When I try to compile, I get a number of "expected areas" directed towards the following segment of code:

public static char encrypt(char c, String k) {
	String fullcrypt = (k + "abcdefghijklmnopqrstuvwxyz");
		for (int i = 0; i < fullcrypt.length(); i++) {
			for (int j = 0; j =< fullcrypt.length(); j++) {
				if (i == j) {
					for (j =< fullcrypt.length(); j++)
						j = j+1;
				}
			}
		}
	fullcrypt = fullcrypt.substring(0,25);
	fullcryptA = fullcrypt.toUpperCase();
	fullcryptB = fullcrypt.toLowerCase();
	char A = fullCryptA.substring(0,1);
	char a = fullCryptB.substring(0,1);
	char Z = fullCryptA.substring(24,25);
	char z = fullCryptB.substring(24,25);
		
	if(a <= c && c <= z)
		return (char)('a' + (c - a + k) % NLETTERS);
	if (A <= c && c <= Z)
		return (char)(A + (c - A + k) % NLETTERS);
		
	return c;
}

I can't see any missing semicolons, parentheses, etc., so I'm not sure where the problem is. Any help would be appreciated.

If there are any other errors with how this code would work (it takes a keyword from the user, eliminates repeats, and then adds the remaining letters in the alphabet to the key, and encrypts the original text to the characters three to the right of the corresponding letter), then please let me know (this was the part of the code I was least sure of).

Thanks so much!

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by jaxi
0

"=<" is not a valid operator.

Also, all for() loops must have three sections ( ; ; ) even if one is not used

0

Oops - got 'em backwards (and the right way around in the rest of the code, go figure). Thanks.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.