I've just done assignment 1.4 and it works correctly with two methods. The first one is for numbers less than twenty or divisible by ten and the second is for the other numbers under 99 (this is so that you don't end up with a hyphen in numbers such as 50). I'm now looking at extending this for larger numbers. Is there an obvious step to take to do all numbers up to 999,999,999,999 or is it better to try to do it in stages eg get numbers up to 999, then 999,999 etc. I know that others will have done it in completely different ways to me but maybe what I have done will sound familiar to someone
As you suggested, there are several approaches to this assignment. I am still working on my third submission, and will probably have more. Paul Wheaton made a good suggestion in another message that really helped me. He said...
For some cattle drive folks I add the requirement that I want them to make a method that introduces some abstraction. The method will take and integer and the value must be in the range of 0 to 999. It will then "say" that value. If you have such a method, writing your main becomes much easier. From within this new method, your task becomes much easier. The whole program falls together.
He's right, once you have done this the program seems to be much easier to write and you can easily add other methods to handle the larger numbers. One other side note, don't forget about negative numbers! Brian
In the assignment I can not see any thing about negative numbers, doing so means: ignore KISS -principle?! So my solution will definitely not include negative numbers, the change is not worthwile to include (imho=in my humble opinion).