F
Frazer
hi,
I had to write a program in my exam to simulate a
cheque writing utility, that would take numbers as input and give me words
as output.
But i just got 9/10 . my lecturer said i could have used a design pattern.
and made it more efficient.
eg
956.23 should be nine hundred and fifty-six dollars and twenty three cents.
what i did was
had two functions one for single digits
eg 6 returns six
and one for double digits (5 in 2nd place returns fifty)
and then I started reading from the back 6 5 9
passed 6 and 9 to the single digit reader.
and passed 5 to the double digit reader.
and then spit out the output. it works fine. but he said it was inefficient.
how could i have improved this?
Thanx
I had to write a program in my exam to simulate a
cheque writing utility, that would take numbers as input and give me words
as output.
But i just got 9/10 . my lecturer said i could have used a design pattern.
and made it more efficient.
eg
956.23 should be nine hundred and fifty-six dollars and twenty three cents.
what i did was
had two functions one for single digits
eg 6 returns six
and one for double digits (5 in 2nd place returns fifty)
and then I started reading from the back 6 5 9
passed 6 and 9 to the single digit reader.
and passed 5 to the double digit reader.
and then spit out the output. it works fine. but he said it was inefficient.
how could i have improved this?
Thanx