How can i convert numbers into symbols of this "-"? Ex. Abcd123 it will become abcd--- | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can i convert numbers into symbols of this "-"? Ex. Abcd123 it will become abcd---

https://code.sololearn.com/cffNrta3i2zL/?ref=app

15th Feb 2018, 3:02 PM
Andrea Galeria
Andrea Galeria - avatar
2 Answers
+ 5
import java.util.Scanner; public class Program { public static void main(String[] args) { String s = new Scanner(System.in).nextLine(); for(int i = 0;i<s.length();i++) { if(s.charAt(i) >= '0' && s.charAt(i) <= '9') { System.out.print("-"); } else System.out.print(s.charAt(i)); } } }
15th Feb 2018, 3:25 PM
Vukan
Vukan - avatar
0
how can i insert that code using a file input stream.. we can read the input inside the file then read it with replacing numbers into '-' ?
20th Feb 2018, 3:40 AM
Andrea Galeria
Andrea Galeria - avatar