Coded Message... Help Please
I have a code that I need help with...
------
Write a program that decodes secret messages read from a text file using an "alphabetic shift." So, for example, a shift might appear as:
ORIGINAL ABCDE...XYZ
SHIFTED. CDEFG...ZAB
You must:
1.) Read the encoded message from the attached MessageIn.txt file,
2.) Count the instance of each character in the file,
3.) The most common character in the message should be an "E". Use this information to calculate the amount of the shift,
4.) Print out the decoded message.
----
here is what i have to work with...
the code that needs to be decoded:
HVWGWGHVSPSGHQCADIHSFSLSFQWGSWVOJSSJSFSLDSFWSBQSR
I have figured out that:
char A in the message (encoded)= M (decoded);
char B = N;
char C = O;
char D = P;
char E = Q;
char F = R;
char G = S;
char H = T;
char I = U;
char J = V;
char K = X;
char L = W;
char M = Y;
char N = Z;
char O = A;
char P = B;
char Q = C;
char R = D;
char S = E;
char T = F;
char U = G;
char V = H;
char W = I;
char X = J;
char Y = K;
char Z = L;
----
I just need help finding out how to write it in java code... also here is what else I have to work with:
:confused:
public class test
{
public static void main(String args[])
{
//Method Number 1 using indexing
String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int i = alpha.indexOf("G");
//Method Number 2 using chars and ASCII values
int j = (int)alpha.charAt(6) - (int)'A';
System.out.println(i+" "+j);
}
}