Created
June 11, 2018 17:10
-
-
Save charsyam/582640373f514a70f935d51f9f4a1328 to your computer and use it in GitHub Desktop.
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 ConvertNumber { | |
public static String convertNumber(String word) { | |
String convertedWord = ""; | |
for (int i = 0; i < word.length(); i++) { | |
char ch = word.charAt(i); | |
if (ch >= '0' && ch <= '9') { | |
ch = '$'; | |
} | |
convertedWord += ch; | |
} | |
return convertedWord; | |
} | |
public static void main(String [] args) { | |
Scanner sc = new Scanner(System.in); | |
String line = ""; | |
while(true) { | |
String word = sc.nextLine(); | |
if ("quit".equals(word)) { | |
break; | |
} | |
String convertedWord = convertNumber(word); | |
line += convertedWord; | |
System.out.println(line); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment