Hi,
I was wondering if someone could help me please.... I am new to java and have been struggling with this for about 2 weeks now!!
At the moment I am just trying to get the program to print out a 5x5 matrix with the alphabet in it, using a 2D array. I then need to encrypt the matrix but I could do with getting this to work first! Any advice would be very much appreciated, also it might be fairly obvious from my code but I'm not very good at this!!
public class Encryption
{
public static void main(String[] args)
{ //naming instance variables
private String Unencoded, FiveLetterKeyword, EncryptedMessage;
//constructor method
public encryption(String U, String F, String E)
{
unencoded = U;
fiveLetterKeyword = F;
encryptedMessage = E;
}
//create 2D string array 5 by 5
String encrypt [][] = new String[5][5];
//create string filled with all letters of the alphabet
String String = new String
("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");
//method for loop to print out the matrix
public void matrix()
//for loop to create matrix rows and columns
{
for (int row = 0; row < encrypt.length; row++)
{
for (int column = 0; column < encrypt[row].length; column++)
System.out.print(encrypt[row][column] + " ");
}
}
//using toCharArray to fill the array with the letters of the alphabet
public static char[][] encrypt()
char aChar [][] = new char [5][5];
char[][] aChar = "abcdefghijklmnopqrstuvwxyz".toCharArray();
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
System.out.print(aChar[i][j]);
}
System.out.println();
}
}
}