Error when creating a Caesar Cipher Program in Java -
I am trying to create a program that changes 'one' to 'e' to 'd' , 'B', etc. I've written some code and received this error message:
Error: Define the main method as the main method found in class EC1: public static void (String [] Args) or a JavaFX application class. Javafx.application.Application
Here is my code:
public class EC1 {private string alphabet = "Abcdefghijklmnopqrstuvwxyzabc"; Public string encrypt () {scanner scan2 = new scanner (System.in); System.out.println ("Enter your message"); String pop = scan2 Tosting (); Int key = 3; String code = ""; For (int i = 0; i & lt; poop.length (); i ++) {int a = ALPHABET.indexOf (poop.charAt (i)); Int keyVal = (key + A)% 26; Replace four VAL = this.ALPHABET.charAt (keyVal); Code + = replaceVal; } return code; }}
After
JVM searches for the main () system to start execution . If the control starts from there, then you need to add the main ()
method to your class inside it and call the encrypt ()
method.
public static zero main (string [] args) {ec1 obj = new ec1 (); String encrypted_value = obj.encrypt (); }
Read more
Comments
Post a Comment