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!

Recommended Answers

"=<" is not a valid operator.

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

Jump to Post

All 3 Replies

"=<" is not a valid operator.

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

Member Avatar

...and certainly DON'T put a loop, within a loop, using the SAME incrementor!!!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.