Last active
July 10, 2018 05:12
-
-
Save tonkatsu7/15cfb8151334a5a5d335b5d0f794cceb to your computer and use it in GitHub Desktop.
CoderByte challenge Letter Change in java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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