Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Problem Calculating change is something that we have been trained to dofrom a young age. For example, without thinking about it, we allknow how

The Problem

Calculating change is something that we have been trained to dofrom a young age. For example, without thinking about it, we allknow how many quarters, dimes, nickels and pennies we shouldreceive if the change from our purchase is 47 cents. In this lab,you will write a program to convert a given amount of money (incents) 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 wecould use 3 dimes and 17 pennies. Or we could use 4 dimes, anickel, and 2 pennies. You get the idea. What we would really liketo do is use a minimal number of coins. For 47 cents, one way touse a minimal number of coins is 1 quarter, 2 dimes, and 2pennies.

For this lab, you will implement a greedy solution for theproblem of calculating change. What isa greedy solution? It is quite simple. Assumeyou want to convert an arbitrary number of cents into coins of thefollowing denominations: dollar, half-dollar, quarter, dime,nickel, and penny. Use as many dollar coins as possible; then, onwhat's left over, use as many half-dollar coins as possible; thenagain as many quarters as possible; then as many dimes as possible;then as many nickels as possible; finally the remainder is inpennies.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

More Books

Students also viewed these Programming questions

Question

In a system with light damping (c Answered: 1 week ago

Answered: 1 week ago