Discussion:
testRoundDown999
(too old to reply)
Akif Hossain
14 years ago
Permalink
okay so just wondering what that meant.

for example if you have 0.999, shuld the output be 99 instead? or does
it mean something else?
David Xingliang Lou (CS 137 Tutor)
14 years ago
Permalink
Post by Akif Hossain
okay so just wondering what that meant.
for example if you have 0.999, shuld the output be 99 instead? or does
it mean something else?
Yes, if the average is 99.9 cents, you should just output 0 dollars and
99 cents.
Akif Hossain
14 years ago
Permalink
Post by David Xingliang Lou (CS 137 Tutor)
Yes, if the average is 99.9 cents, you should just output 0 dollars and
99 cents.
ya but my program does round it down. so i still see 0 dollars 99
cents.

like when i pass in an array of size 1 with value 0.999, the output i
get is 0 dollars 99 cents
same with 5.999, i get 5.99

any comments on how to avoid that?
David Xingliang Lou (CS 137 Tutor)
14 years ago
Permalink
Post by Akif Hossain
Post by David Xingliang Lou (CS 137 Tutor)
Yes, if the average is 99.9 cents, you should just output 0 dollars and
99 cents.
ya but my program does round it down. so i still see 0 dollars 99
cents.
like when i pass in an array of size 1 with value 0.999, the output i
get is 0 dollars 99 cents
same with 5.999, i get 5.99
any comments on how to avoid that?
What if the average is 99.99 cents? How about 99.999 cents? Does your
program still output 99 cents?

Loading...