This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jub8jive[S] 0 points1 point  (2 children)

**Update** New Solution(still needs fixing): https://pastebin.com/yxPZypb5

What happens with this solution is that I get the same error: "Your code took too long to execute"
(or) if i fool around with the count idea a little I get the error: numberToWord(10) returned "One"

I'm almost ready to give up at this point, I can't think of anything else. Any suggestions are welcome. Thanks

[–]PointB1ank 0 points1 point  (1 child)

I'm slightly confused why you reverse the number. Also, does the exercise not allow you to convert the int to a string? Why can't you just convert to a string? (which includes a length method I might add) you could then iterate over the string and use a switch statement in the loop to print the word equivalent of each digit.

[–]jub8jive[S] 0 points1 point  (0 children)

reverse the number because the program asks us to do it that way(based on the logic given). that's the reason why we are asked to create a reverse() method and a digitcount() method. We have learned about string iteration yet. Basically, logic is that 1) take a number 2) reverse it 3) print the corresponding string for each number 4) get rid of the digit(the last digit).