No numeral challenge | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

No numeral challenge

Please, I don't seem to find solutions to this problem. It is always failing only Test Case #3 of the code coach. The problem is to convert any number found in the sentences inputted into word. Please what I'm I doing wrong? https://www.sololearn.com/coach/64?ref=app https://sololearn.com/compiler-playground/csaQV35S8Xwc/?ref=app

28th Feb 2024, 7:19 AM
Oluwaseyi Aremu
Oluwaseyi Aremu - avatar
4 Respuestas
+ 3
Oluwaseyi Aremu , what about the case for '10'. You commented this line of your code. Also it should be the first case in switch-case construction, otherwise '10' will be interpreted like 'one zero'. Hope it helps you.
28th Feb 2024, 7:29 AM
TheWh¬°teCat ūüáßūüá¨
TheWh¬°teCat ūüáßūüᨠ- avatar
+ 1
Oluwaseyi Aremu review case '10'. It is a mistake to place more than one character between single quotation marks, which are for single characters. You must change the way it tests for "10". Maybe under case '1' use if/else to check whether the next character is '0'. But you would have to check further that the character after that is non-numeric so it handles "100" correctly by not converting it. Overall, the solution would work better to compare whole words instead of single characters. TIP: Let cin break up the input into words like the code below. It reads a string until it encounters a blank space, i.e. it reads one word at a time. string word; while (cin >> word) { ... }
28th Feb 2024, 8:56 AM
Brian
Brian - avatar
+ 1
I've gotten a way around it and solved it. It works for only ten thou. Thanks Brian
28th Feb 2024, 10:47 AM
Oluwaseyi Aremu
Oluwaseyi Aremu - avatar
0
Thanks for your assistance, I have tried it but still the same
28th Feb 2024, 8:37 AM
Oluwaseyi Aremu
Oluwaseyi Aremu - avatar