1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Lady bird [3.3K]
3 years ago
5

Suppose we wanted to make change for purchases and wanted to use the least number of coins possible. Here is a greedy algorithm:

for the change amount due, we always use the largest-face-value coin first. Assume we have only coins of quarters ($.25), twenties ($.20), and pennies ($.01). Assume the change is $.40: a. what would be the coins and their numbers obtained by the greedy algorithm above
Computers and Technology
1 answer:
love history [14]3 years ago
5 0

Answer:

Explanation:

The following code is a Python function that takes in the amount of change. Then it uses division and the modulo operator to calculate the number of coins that make up the changes, using the greatest coin values first.

import math

def amountOfCoins(change):

   print("Change: " + str(change))

   quarters = math.floor(change / 0.25)

   change = change % 0.25

   dimes = math.floor(change / 0.20)

   change = change % 0.20

   pennies = math.floor(change / 0.01)

   print("Quarters: " + str(quarters) + "\nDimes: " + str(dimes) + "\nPennies: " + str(pennies))

You might be interested in
How do I get rid of this little tool bar????
Serhud [2]

Answer:

settings>Accessibility>Touch>AssistiveTouch>Turn off

Explanation:

4 0
2 years ago
In which type of attack does the user respond to several external communication requests? Harry wants to watch a movie online by
Shkiper50 [21]

Answer:

They normaly do that to put a virus on your device And hack into your private info like passwords and credit cards and stuff like that

Explanation:

Always watch a movie leagly

3 0
3 years ago
They will wash the car change into tag question​
valentina_108 [34]

Answer:

They will wash the car, won't they?

Explanation:

A tag question usually comes after an independent clause. The tag question is most times attached with the intent of affirming the statement made in the independent clause. Our independent clause in the answer above is; "They will wash the car". The tag question, "Won't they?" is meant to affirm that statement.

Another example is, "They are going to school, aren't they?" In this example also, the independent clause makes a sentence that is to be confirmed by the tag question.

8 0
2 years ago
What is the name of the hardware device that is used to write the data from hard disk to CD​
mart [117]

it is called a disk drive

4 0
2 years ago
Read 2 more answers
JAVA
Leokris [45]

Answer:

Answer provided in screenshot, not really too happy with my implementation but it works.

Explanation:

Iterate through months, handling logic for every 12 months to get the raise.

8 0
2 years ago
Other questions:
  • What are the cause of eye strain during computer usage?
    7·1 answer
  • Take some time to do some research about small businesses in your area. Select one and using HTML design a simple site that educ
    11·1 answer
  • ______ allows you to see through a slide background or a color.
    10·1 answer
  • The variable 'a' starts with the value 1 The variable 'b' starts with the value 10 The variable 'c' starts with the value 100 Th
    11·1 answer
  • The monkey-and-bananas problem is faced by a monkey in a laboratory with some bananas hanging out of reach from the ceiling. A b
    8·1 answer
  • A store owner keeps a record of daily transactions in a text file. Each line contains three items: The invoice number, the cash
    7·1 answer
  • Which of the following countries have mixed-market economy
    5·1 answer
  • * 8) Embedded operating systems are specialized software meant only to manage the
    7·1 answer
  • Which of the following internet protocols is used to request and send pages and files on the World Wide Web
    13·1 answer
  • LIST THE 7 BEST PROGRAMMING MOVIES 2020-2021.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!