This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Right, now..... I've done assignment 4a, but after marking, two comments i've been given are:- "Notice how a lot of array elements share words that are the same?" & "How about using more than one array? Then you can use combinations of values from the arrays (when necessary) to print out what you want"
So in other words, I can trim my code down (what a pain I can't post it!). I can't see how I can share parts of words. i.e. If I type 23 - the program outpurs twenty-three and If I type 24 - the program outpurs twenty-four
I can share the 'twenty' bit, right? But how??
John Bonham was stronger, but Keith Moon was faster.
ahhh, 4a-Say... what fond memories. the hint about using "more than one array" is very good... i assume you are reading the input (23) and then printing a string (twenty-three) accordingly. maybe you could have another method to handle values in the 2nd array.
right, Steve, you share the "twenty" part (for example). Fill one array with numbers that behave similar, and another array with the other similar behaving numbers. Add the "-" seperately in case the input number is concatenated. Hope you have fun cracking this assignment as I had! Juliane
Joined: Sep 23, 2002
Joined: Sep 23, 2002
Originally posted by juliane gross: right, Steve, you share the "twenty" part (for example). Fill one array with numbers that behave similar, and another array with the other similar behaving numbers. Add the "-" seperately in case the input number is concatenated. Hope you have fun cracking this assignment as I had! Juliane
Surely that therefore means I have to search the inputted string, to check for the number "2", and do a tets to see if there is another charcater after that?? Also, when I search the inputted strings, I have to find out what the values of them are?? Am i going on the right lines - needing to use string seraches and such like?? It's a freezing cold, dank and dark Friday evening in London, and I feel as though this assignment is out to get me.
Joined: Apr 12, 2001
think about it this way: when you visually read a number, your brain first looks to see how many digits there are in the number and then processes each digit according to the value associated with its position in the number. of course, you process from largest to smallest. so how does that convert to a java program? look at the number to see how many places there are and then process each digit according to its position in the string. in 4a-Say, you are only dealing with 0-99... so you will only have 2 digits to worry about. also, think about how you can use math to see if a number is greater than 9...
Hi Steve. I think the example in the assignment is quite useful ... "I want to type .. 22 .. and see twenty-two", especially when when you combine it with Marilyn's suggestion that you "separate the tens and ones with math." and the hint about using "more than one array" It's two two's, right ? Or is one two more significant (maths-wise) than t'other ? BTW how would you go about converting 22 to hex ? [ December 20, 2002: Message edited by: David Mason ]
Marilyn de Queiroz
Joined: Jul 22, 2000
Converting to hex is not required to complete this assignment. [ December 21, 2002: Message edited by: Marilyn de Queiroz ]
David, it's a great analogue, but I guess Marilyn wants Steve to remain focused. "Zen and the art of Nitpickin'" sort of thing. Sometimes when one is stuck on a problem, one is like an astronaut floating around in space, you need exactly the right nudge to get where you have to go, but if too hard or in the wrong direction, then it's very hard to get back on track. Beam me up Scotty... -Barry (4b or not 4b THAT is the question.)
So really, there's a lot more to it than what the question asks??
There have been times when my response to a nitpick has been to change a single character in my program. There have been times when my response to a nitpick has been to rethink my entire approach to a problem and essentially rewrite the program (or section of a program). Most times things fall somewhere in between. ***** There are numerous lessons to be learned from the Say assignments. One is to find recurring patterns in a problem and to take advantage of those patterns when building a solution. Another is to learn not to encode a single piece of information in more than one place (the DRY princple -- Don't Repeat Yourself). "20" -> "twenty" "21" -> "twenty-one" "22" -> "twenty-two" ... "30" -> "thirty" "31" -> "thirty-one" and so on. If your program is somehow capturing in more than one place the fact that "20" translates to "twenty," or that "30" translates to "thirty," then there're definitely ways to improve it. [ December 21, 2002: Message edited by: Michael Matola ]