Hi...

i am trying to run this program...and it stays that it does not have a main method...

public static void...

but i have the public static final int...
please let me know how i can get this program to run..thanks

public class CaesarCipher {
    
public static final int ALPHASIZE = 26;

public static final char [] alpha = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
protected char[] encrypt = new char[ALPHASIZE];
protected char[] decrypt = new char[ALPHASIZE];
public CaesarCipher() {
    for (int i=0; i<ALPHASIZE; i++)
        encrypt[i] = alpha[(i + 3) % ALPHASIZE];
    for (int i=0; i<ALPHASIZE; i++)
        decrypt[encrypt[i] - 'A'] = alpha[i];
    }
    /** Encryption Method */

 public String encrypt(String secret) {
 char[] mess = secret.toCharArray();
 for (int i=0; i<mess.length; i++)
     if (Character.isUpperCase(mess[i]))
         mess[i] = encrypt[mess[i] - 'A'];
 return new String(mess);
    }
    /** Decryption Method */
 public String decrypt(String secret) {
     char[] mess = secret.toCharArray();
     for (int i=0; i<mess.length; i++)
         if (Character.isUpperCase(mess[i]))
             mess[i] = decrypt[mess[i] - 'A'];
     return new String(mess);
 }
}

Recommended Answers

add the following method:

public static void main(String[] args) {
		CaesarCipher cc = new CaesarCipher();
		
	}
Jump to Post

All 3 Replies

i also need to write the program for the lower case letters...i will need to do the same thing right?? like using the same method..

Anybody....i am really lost and need help...

Member Avatar

add the following method:

public static void main(String[] args) {
		CaesarCipher cc = new CaesarCipher();
		
	}
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.