• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Approach for "Say", part a

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are a couple of different approaches I can see for the lab, but I'm not sure which to pursue. I can see populating an array with all the strings needed, then just outputting based on position... but is that using KISS? Or just bad programming?
Since I'll assume the above approach isn't what we're looking for, my guess is that we're going to parse the input and go from there.
Any comments or suggestions would be swell
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you noticed the link on the assignment page build and access an array, that may be where you got your first impression from. It so happens that impression is the correct one. Start with a populated array and go from there.

However, you still need to parse the input which will be the number (i.e. "29") the user inputs which will cause the application to print out the number in English (i.e. "twenty-nine"). So maybe I don't understand your question?

On second reading, you will need to use the position of the string in the array, but I wouldn't recommend writing an array with 100 numbers in it.
[ March 12, 2004: Message edited by: Marilyn de Queiroz ]
 
dav mccartney
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did notice the link. Thanks
I believe you answered my question when you mentioned "parse"... I just wanted to make sure that, in the spirit of KISS, we're not expected to just populate an array with strings "zero" through "ninety-nine" and spit out from there.
 
dav mccartney
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my nitpicking for 4a, I was told "Why not parse the number once and then use the math operators to separate the numbers?"
I'm somewhat confused by this. If I parse the numbers with Integer.parseInt(<mystring>.substring(positions...)), what application is there for the math operators to "separate the numbers"?
Perhaps I'm overthinking things, or I don't understand the suggestions I received.
Any advice?
Thanks,
dav
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am in the same situation as David with this one. I have been told to use the math operators to pull out tens & ones from numbers.
Maybe i'm missing something too, but i don't really see how division or subtraction etc. could help with this assignment? Am i just blind!!!
Thanks in advance!
Celine
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you do arithmetic manually, you have a tens column and a ones column. If you think in those terms, you'll be on the right track. In other words, "75" breaks down into 7 tens and 5 ones. So, programatically, in Java, think how you can break 75 down into 7 tens and 5 ones using math.
 
dav mccartney
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ding!
<insert lightbulb on here>
 
celine mcgowan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah... The penny finally drops!!! Thanks Marilyn!
Did you get it David? I think i've got it now. I'm gonna re-send it to Jason & see what happens.
Fingers crossed!
Cel
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't realize I was being so cryptic... I should get a job as a sphinx or something.
 
dav mccartney
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I got it, Celine. We'll see what Jason has to say
As for Jason as a sphinx... I'll book your trip to Egypt after I get my code back
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic