0
No Numerals Problem Help
import java.util.*; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); String sc = input.nextLine(); String sc1 = sc.replaceAll("0", "zero").replaceAll("10", "ten").replaceAll("1", "one").replaceAll("2", "two").replaceAll("3", "three").replaceAll("4", "four").replaceAll("5", "five").replaceAll("6", "six").replaceAll("7", "seven").replaceAll("8", "eight").replaceAll("9", "nine"); System.out.println(sc1); } }
4 Answers
+ 2
Replace 10 before 0
+ 2
Replacing every occurance in the whole line will give wrong results.
"10 out of 1001 will fail"
0
Does anbybody know why this code wonât work for the no numerals problem? There is only one test case that is not working
0
Ah thank you Simba!