1 Replies - 2394 Views - Last Post: 05 February 2011 - 08:42 PM Rate Topic: -----

#1 lashbandi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 06-February 10

Ceasar Cipher- Does not have a main method!?!

Posted 05 February 2011 - 08:23 PM

Hi...

i am trying to run my 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);
 }
}

    
 


Is This A Good Question/Topic? 0
  • +

Replies To: Ceasar Cipher- Does not have a main method!?!

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8347
  • View blog
  • Posts: 31,910
  • Joined: 06-March 08

Re: Ceasar Cipher- Does not have a main method!?!

Posted 05 February 2011 - 08:42 PM

To run a Java program you need a public static void main(String[] args) method
which is an entry point to your class

As far as Ceasar cypher is concerned here is an example

http://www.dreaminco...-ceasar-cipher/
which is the first of my 8 Secret Code tutorials
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1