import java.util.Scanner;
public class data {
public static int setoriginal() { //prompt user to input 4 digit number
int n = 0;
int l = 0;
do {
Scanner input = new Scanner(System.in);
System.out.println("Please enter a 4 digit number: ");
n = input.nextInt();
if (n >= 1000 && n <= 9999) {
break;
} else {
System.err.
printf("You did not enter 4 digits\n");
}
l = l + 1;
}
while (l < 3);
return n;
} //end method
public static int encrypt(int n) { //encrypt number inputted by user
int e1 = (((n / 1000) + 7) / 10);
int e2 = ((((n % 1000) / 100) + 7) / 10);
int e3 = ((((n % 100) / 10) + 7) / 10);
int e4 = ((((n % 10) / 1) + 7) / 10);
int e = e1 * 1000 + e2 * 100 + e3 * 10 + e4;
int firstPart = e % 100;
int lastPart = e / 100;
int result = firstPart * 100 + lastPart;
return result;
} //end method
public static int decrypt(int result) { //decrypt encrypted number
int d1 = (((result / 1000) - 7) * 10);
int d2 = ((((result % 1000) / 100) - 7) * 10);
int d3 = ((((result % 100) / 10) - 7) * 10);
int d4 = ((((result % 10) / 1) - 7) * 10);
int d = d1 * 1000 + d2 * 100 + d3 * 10 + d4;
int firstPart1 = d % 100;
int lastPart1 = d / 100;
int result1 = firstPart1 * 100 + lastPart1;
return result1;
} //end method
public static int decrypt1(int n) { //decrypted number inputted by user
int dd1 = (((n / 1000) - 7) * 10);
int dd2 = ((((n % 1000) / 100) - 7) * 10);
int dd3 = ((((n % 100) / 10) - 7) * 10);
int dd4 = ((((n % 10) / 1) - 7) * 10);
int dd = dd1 * 1000 + dd2 * 100 + dd3 * 10 + dd4;
int firstPart1 = dd % 100;
int lastPart1 = dd / 100;
int result1 = firstPart1 * 100 + lastPart1;
return result1;
} //end method
public static void display(int n, int result, int result1) { //output results
System.out.println("Originl number is: " + n);
System.out.println("\nEcrypted numebr is: " + result);
} //end method
public static void display1(int n, int result, int result1) { //output results
System.out.println("Originl number is: " + n);
System.out.println("\nDecrypted numebr is: " + result1);
} //end method
public static void getOriginal(int n) { //return original number
System.out.println("The original number is: \n" + n);
} //end method
public static void getEncrypt(int n, int result) { //return encrypted number
System.out.println("The encrypted number is: \n" + result);
} //end method
public static void main(String[]args, int result, int n, int result1) {
int m = 0;
Scanner input1 = new Scanner(System.in);
System.out.print("\nPlease choose from the following menu ");
System.out.print("\n1. Enter an original number");
System.out.print("\n2. Encrypt the number and print it");
System.out.print("\n3. Decrypt a number and print it");
System.out.print("\n4. Quit\n");
m = input1.nextInt();
while (m < 1 || m > 4) {
System.out.print("Error choose a number from 1-4");
m = input1.nextInt();
}
if (m == 1) {
setoriginal();
main(args, m, m, m);
}
else if (m == 2) {
if (setoriginal() == 0) {
System.out.
("Please enter an original number first");
main(args, m, m, m);
} else {
encrypt(n);
display(n, result, result1);
main(args, n, result, result1);
}
} else if (m == 3) {
if (encrypt(n) < 0) {
System.out.
print("Please encrypt your number first");
main(args, n, result, result1);
} else {
decrypt(n);
display1(n, result, result1);
main(args, n, result, result1);
}
} else if (m == 4) {
System.exit(0);
}
}
}
I keep getting a message saying "Selection does not contain a main type" :S But i do have a main. Any idea what the issue could be? Thanks in advance for the help guys.