Okay, so for a school project I am attempting to make a method that will take a file, use a caesar cipher to 'encrypt' it, and then output the new encrypted word to an output file, reading in all the words of the file to leave us with a separate encrypted file.
The problem I'm running into is I get a
"Unexpected type. Required: variable. Found: value" error
whenever I try to replace the character with the new one.
Here's my encryption method, so hopefully that will be enough to find the problem.
public static void encrypt(File inputFile, int key) throws FileNotFoundException
{
char[] alpha = new char[26];
for(char ch = 'a'; ch <= 'z'; ch++)
{
int i = 0;
alpha[i] = ch;
i++;
}
Scanner in = new Scanner(inputFile);
while(in.hasNext())
{
String word = in.next();
word = word.toLowerCase();
for(int i = 0; i < word.length(); i++)
{
for(int j = 0; j < alpha.length; j++)
{
if(word.charAt(i) == alpha[j])
{
word.charAt(i) = alpha[j + key];
}
}
}
}
}