Loading...
Loading...
Loading...
Two friends send secret notes by moving every letter forward in the alphabet by k places. After z comes a again, and after Z comes A. Capital letters stay capital and small letters stay small. Spaces, digits and punctuation are not changed. Read the note and k, and print the coded note.
Example 1
Input
Hello, World! 3
Output
Khoor, Zruog!
Example 2
Input
xyz 3
Output
abc
x, y, z go past z and wrap back to a, b, c.
Try the problem first. Open one hint at a time.
Turn a letter into its position: ch - 'a' is 0 for a and 25 for z.
Add k and take % 26 to wrap around; then add 'a' back and cast to char.
Do the same with 'A' for capital letters, and append other characters as they are.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor