This is probably a simple fix but I can't seem to solve it.
I am trying to add an integer to the ascii value of characters during a for loop.
It is giving me the error that the program expects a variable rather than a value. How can I do what I am trying to do here?
Here is the code:
public boolean toggleEncryption(){
if(encrypted == false){
for(int i = 0; i < sentence.length(); i++){
if(sentence.charAt(i) >= 65 && sentence.charAt(i) <= 90){
int x = (int)sentence.charAt(i);
x += key;
while(x > 90){
x = x - 26;
}
sentence.charAt(i) += (char)x;
}
}
}
return encrypted;
}
the line sentence.charAt(i) += (char)x;
is not working for me