id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com apcsa-encryption > apcsaEncryptCaesarString
prev  |  next  |  chance

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.

HINT
Use 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)

public String apcsaEncryptCaesarString(String str) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 350

Copyright Nick Parlante 2017 - privacy