0

Find error in the (fail in the 3 rd test case)code . No numerals in codecoach

import java.util.Scanner; import java.lang.String; public class Name { public static void main(String args[]) { Scanner sc=new Scanner(System.in); String st=sc.nextLine(); int k; for(int i=0;i<st.length();i++) { k=st.charAt(i); if((k>48)&&(k<58)) { chandu.fun(k); i++; } System.out.print(st.charAt(i)); } } } class chandu{ static void fun(int i) { switch(i) { case 49: System.out.print("one"); break; case 50: System.out.print("two"); break; case 51: System.out.print("three"); break; case 52: System.out.print("four"); break; case 53: System.out.print("five"); break; case 54: System.out.print("six"); break; case 55: System.out.print("seven"); break; case 56: System.out.print("eight"); break; case 57: System.out.print("nine"); break; /* case 48: System.out.print("zero"); break; */ } } }

21st Mar 2020, 10:18 AM
V Chandu
V Chandu - avatar
5 Respuestas
+ 2
V Chandu , I think the problem is that you don't check for 10 in your tests, also uncomment the test for 0.
21st Mar 2020, 10:28 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 2
V Chandu you have to include number 10,without num 10 it will print onezero instead of 10. https://www.sololearn.com/discuss/2192827/?ref=app
21st Mar 2020, 10:28 AM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 2
V Chandu if you have any doubt you can use the search bar. You will find lots of threads as similar to yours.
21st Mar 2020, 10:45 AM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
0
TheWh¡teCat 🇧🇬 let me check thank you!👍
21st Mar 2020, 10:38 AM
V Chandu
V Chandu - avatar
0
You are welcome V Chandu 🐱
21st Mar 2020, 10:47 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar