My task is:
The Captain Crunch decoder ring works by taking each letter in a string and adding 13 to it. For example, ’a’ becomes ’n’ and ’b’ becomes ’o’. The letters “wrap around” at the end, so ’z’ becomes ’m’.
Write a method that takes a String and that returns a new String containing the encoded version. You should assume that the String contains upper and lower case letters, and spaces, but no other punctuation. Lower case letters should be transformed into other lower case letters; upper into upper. You should not encode the spaces.
package junk;
public class Main {
public static void main(String[] args) {
String alphabet = "abcdefghijklmnopqrstuvwxyz";
int index = 0;
while (index < alphabet.length ()) {
char letter = alphabet.charAt (index);
System.out.println (letter);
index = index + 1;
}
}
}
So far my program only gives me output of all of the alphabets in the string. How should I take a from the string and get n, take b and get o consecutively until I take z and get m. Please Help :(