subject
Computers and Technology, 06.06.2020 23:03 bbb4951

Calculating change is something that we have been trained to do from a young age. For example, without thinking about it, we all know how many quarters, dimes, nickels and pennies we should receive if the change from our purchase is 47 cents. In this lab, you will write a program to convert a given amount of money (in cents) into change. Notice, however, that there are many ways to calculate change. That is, if our change is 47 cents, we could use 47 pennies. Or we could use 3 dimes and 17 pennies. Or we could use 4 dimes, a nickel, and 2 pennies. You get the idea. What we would really like to do is use a minimal number of coins. For 47 cents, one way to use a minimal number of coins is 1 quarter, 2 dimes, and 2 pennies.
For this lab, you will implement a greedy solution for the problem of calculating change. What is a greedy solution? It is quite simple. Assume you want to convert an arbitrary number of cents into coins of the following denominations: dollar, half-dollar, quarter, dime, nickel, and penny. Use as many dollar coins as possible; then, on what's left over, use as many half-dollar coins as possible; then again as many quarters as possible; then as many dimes as possible; then as many nickels as possible; finally the remainder is in pennies.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, dondre54
in 2007, floridians died in alcohol-related collisions.a.  501b.  1,051c.  5,015d.  10,839
Answers: 1
image
Computers and Technology, 22.06.2019 14:30, SKYBLUE1015
What percentage of companies is projected to use social media to locate new employees in 2012
Answers: 2
image
Computers and Technology, 22.06.2019 16:00, raizagisselle1273
If a client wants to make minor edits, what should he/she use?
Answers: 3
image
Computers and Technology, 23.06.2019 04:00, china236
In a word processing program, such as microsoft word, which feature to you choose the desired picture enhancement?
Answers: 2
You know the right answer?
Calculating change is something that we have been trained to do from a young age. For example, witho...

Questions in other subjects:

Konu
Mathematics, 04.11.2019 13:31
Konu
Mathematics, 04.11.2019 13:31