I need some help for the Say assigment. I use 2 arrays, one for the numbers less than 20, another for the tens(20, 30..). here is my code: if number less than 20 print units else if number is tens print tens else print tens + "-" + unit I was nitpicked for printing tens twice here. but how do I extract the print statement out of the if-else clause?
Your first if-clause is fine. But you only need one more, for the case that the number is 20 or greater. Then, within that second clause, create another clause testing whether the number is an even multiple of ten or not. If it is, add the hyphen-ones. If it is not, no more printing needed. Thus, no duplicate print statements. ------------------