0
Why my code is giving wrong output for 6900 it is showing 'Six Nine' but it should show ' Six Nine Zero Zero'.
Please help https://code.sololearn.com/cgFB4oIY7Y4C/?ref=app
3 Réponses
+ 4
Because s = 96 after first while loop.
+ 2
Hi Ravi Chauhan
If I understand it right you reverse the number.
123 -> s = 321
1037 -> s = 7301
But now check s when you enter a number with a 0 at the end:
120 -> s = 12
6900 -> s = 96
Because s is an Integer and Integers don't start with 0's. So you lose them.
Maybe it helps when you use String for s.
But I guess it is easier to use an ArrayList to store each digit. Then you can loop through the list from the end.
0
how about this?
https://code.sololearn.com/cLv64qxzainq/?ref=app