Created
October 16, 2013 16:39
-
-
Save imryan/7010889 to your computer and use it in GitHub Desktop.
Replace chars in a string.
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.Scanner; | |
| public class Replace { | |
| public static void main(String[] args) { | |
| // Declare variables | |
| Scanner sc = new Scanner(System.in); | |
| String word = "", newWord = ""; | |
| // Get input | |
| word = sc.nextLine(); | |
| // Encode string | |
| newWord = word.replace('i', '!'); | |
| newWord = newWord.replace('s', '$'); | |
| // Output string | |
| System.out.println(newWord); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment