0

i don't get this greedy thingy, because i don't know what are these nickles, pennies, cents :confused: what do? However i am just amusing that its about something we to do with rounding floating numbers. Could anyone please explain it to me? Thanks

3 Answers 3

2

Good question in an international teaching environment. U.S. currency is based on the Dollar, as you have probably learned at some point. We also have coins that represent a fraction of $1 (one dollar). They are:

penny    $ 0.01  (also known as a cent - 100 cents = 1 dollar)
nickel   $ 0.05
dime     $ 0.10
quarter  $ 0.25

We have other coins, but for the purpose of this pset, you do not need to worry about them.

The assignment is indeed about rounding of floats, and, more importantly, about how floats are stored in a computer, but not perfectly accurately. This pset will demonstrate that if you don't handle floats correctly, you will lose accuracy.

The assignment, simply put, is this: You are given a number such as $2.35 (two dollars and 35 cents). What is the minimum number of the coins listed above needed to make that amount? Note: it just has to output the minimum number of physical coins, not the number of each or any other variation.

In this case, $2.35, it would be 10 coins - 9 quarters and 1 dime. It's that simple. Input would always have no more than 2 decimal points, maybe 1 or maybe none. Your job is to figure out a program to calculate the minimum number of coins. That's it!

If this answers your question, please accept this answer to close the question. Let's keep up on forum maintenance. ;-)

1

The USA have the dollar as their currency. The dollar has its fractions, and those are called Penny, Nickel, Dime and Quarter. Each dollar is the same as 100 cents Their values respectively are:

  • Penny = $0.01 = 1 cent
  • Nickel = $0.05 = 5 cents
  • Dime = $0.10 = 10 cents
  • Quarter = $0.25 = 25 cents

What you have to do is read a float that will represent the dollars (for example 3.15, note that the dollar sign will not be included). Then you need to convert that to cents, and then output the minimum number of coins needed to give that amount to the user.

0

For those who are not living in US but want to understand the currency for pset1, here is a simple chart given by a member Brenda Anderson.

1 dollar = 100 cents 1 quarter = 25 cents 1 dime = 10 cents 1 nickel = 5 cents 1 penny = 1 cent

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .