Skip to content

Instantly share code, notes, and snippets.

@charsyam
Created June 11, 2018 17:10
Show Gist options
  • Save charsyam/582640373f514a70f935d51f9f4a1328 to your computer and use it in GitHub Desktop.
Save charsyam/582640373f514a70f935d51f9f4a1328 to your computer and use it in GitHub Desktop.
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