| about | help | code help+videos | done | prefs |
apcsaEncryptCaesarString
(EASY) Given an input String, return the String after a one-character Caesar cipher where all the input letters are shifted up one letter. Precondition: the input String will have only capital letters in it. HINTUse charAt to extract a char at each location. char data can be treated as numbers in many important ways. Remember that to get all the characters in a String, you can use a for loop. Here's an example.
public String apcsaEncryptCaesarString(String str) {
String out = "";
for (int i = 0; i < str.length(); i++)
{
char c = str.charAt(i);
// some other stuff happens to c
// right now we are adding it back in unchanged
out += c;
}
return out;
}
apcsaEncryptCaesarString("ABC") → "BCD" apcsaEncryptCaesarString("HI") → "IJ" apcsaEncryptCaesarString("ZZTOP") → "AAUPQ" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 350
Copyright Nick Parlante 2017 - privacy