Some elusive syntax errors
807603Feb 8 2008 — edited Feb 9 2008I'm new to Java, and I piced together a few programs. I tried compiling this little program which is supposed to encrypt an argument and spit out the results.
class Square {
public static void main(String[] arguments) {
String text = "";
text = arguments[1];
String inOut = "";
inOut = arguments[0];
inOut = inOut.toUpperCase();
if (inOut == "ENCRYPT") {
System.out.println();
System.out.println("DarkFelineSquareEncrypt");
System.out.println(text);
String author = "Allen Li";
char authorLetters[] = author.toCharArray();
char lett[] = text.toCharArray();
int square = 0;
int sq = 0;
for (sq = 0; sq > -5; sq++) {
square = sq^2;
if (square >= lett.length) {
break;
}
}
char letters[] = new char[square];
int extra = square - lett.length;
for (int extraCount = 0; extraCount < extra; extraCount++) {
letters[lett.length + extraCount] = authorLetters[extraCount % 8];
}
for (int copyCount = 0; copyCount < lett.length; copyCount++) {
letters[copyCount] = lett[copyCount];
}
for (int count = 0; count < sq; count++) {
for (int count2 = 0; count2 < sq; count2++) {
int count3 = count + (sq * count2);
if (count3 >= square) {
break;
}
System.out.print(letters[count3]);
}
}
}
else if (inOut == "DECRYPT") {
System.out.println();
System.out.println("DarkFelineSquareDecrypt");
System.out.println(text);
char authorLetters[] = author.toCharArray();
char letters[] = text.toCharArray();
int square = 0;
int sq = 0;
booean work = true;
for (sq = 0; sq > -5; sq++) {
square = sq^2;
if (square == letters.length) {
break;
}
else if (square > letters.length)
System.out.print("That is not a valid encryption");
work = false;
break;
}
}
if (work == true) {
for (int count = 0; count < sq; count++) {
for (int count2 = 0; count2 < sq; count2++) {
int count3 = count + (sq * count2);
if (count3 >= square) {
break;
}
System.out.print(letters[count3]);
}
}
}
}
else {
System.out.print("Error:Please state ENCRYPT or DECRYPT");
}
}
}
I get :
Square.java:83: illegal start of type
else {
^
Square.java:87: class, interface, or enum expected
}→
^
2 errors
I counted the brace, but they all seem to be there.
I would appreciate advice!
PS how would one go about turning code into an application?