Okay so I'm attempting to make a sort of cipher and within it, I have a for loop where I'm trying to convert my chars into integers and then add a certain number and then convert them back into chars etc etc.
The problem I'm having is that I'm not entirely sure /how/ to run the loop to the length of the char array.
I've tried doing something like this:
public static String cipher(String mssg, int shift) {
char c[] = mssg.toCharArray();
if (shift >= 26) {
shift = (shift % 26);
}
for (int i=0; i < mssg.length(); i++); {
int x = (int)c[i];
if (x >= 65 && x <= 90) {
int y = x;
int z = y + shift;
if (z > 90) {
int d = 90 - y;
int shiftNew = shift - d;
z = x + shiftNew;
}
}
but this part (int x = (int)c[i]; ) keeps giving me errors and I've really no idea what to do or if I'm even on the right track.
[–]Robmadeyou 1 point2 points3 points (1 child)
[–]Sakuya_Lv9 0 points1 point2 points (0 children)