Skip to content

Instantly share code, notes, and snippets.

@tonkatsu7
Last active July 10, 2018 05:12
Show Gist options
  • Save tonkatsu7/15cfb8151334a5a5d335b5d0f794cceb to your computer and use it in GitHub Desktop.
Save tonkatsu7/15cfb8151334a5a5d335b5d0f794cceb to your computer and use it in GitHub Desktop.
CoderByte challenge Letter Change in java
import java.util.*;
import java.io.*;
class Main {
public static String LetterChanges(String str) {
char[] chars = str.toCharArray();
for (int i = 0; i < chars.length; i++) {
if (Character.isLetter(chars[i]))
if (('a' <= chars[i] && chars[i] < 'z') || ('A' <= chars[i] && chars[i] < 'Z'))
chars[i] = (char)(chars[i] + 1);
else
chars[i] = (char)(chars[i] - 25);
switch (chars[i]) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
chars[i] = (char)(chars[i] - 32);
}
}
return new String(chars);
}
public static void main (String[] args) {
// keep this function call here
Scanner s = new Scanner(System.in);
System.out.print(LetterChanges(s.nextLine()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment