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
tekilochka [14]
3 years ago
13

Write a program with total change amount in pennies as an integer input, and output the change using the fewest coins, one coin

type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies.

Computers and Technology
1 answer:
Serjik [45]3 years ago
3 0

Answer:

Here is the Python program:

def FewestCoinVals():  # function to output change using fewest coins

 total_change = int(input('Enter change amount in pennies: '))

#prompts user to enter total change amount in pennies

 if total_change <= 0:  # if value of total_change is less or equal to 0

   print('no change')  # prints no change

 else:  # if value of total_change is greater than 0

   dollars = total_change // 100  

#calculate value of dollars by dividing total_change by 100

   total_change %= 100   #take mod of value of total_change with 100

#calculate value of quarters by dividing total_change by 100

   quarters = total_change // 25

   total_change %= 25  #take mod of value of total_change with 25

#calculate value of dimes by dividing total_change by 100

   dimes = total_change // 10  

   total_change %= 10  #take mod of value of total_change with 10

#calculate value of nickels by dividing total_change by 100

   nickels = total_change // 5

   total_change %= 5  #take mod of value of total_change with 5

   pennies = total_change  

#value of pennies is equal to value of total_change

#the if elif statement checks for the singular and plural coin names

   if dollars >1:

       print('dollars: ',dollars)

   elif dollars ==1:

       print('dollar: ',dollars)

   if quarters > 1:

       print('quarters: ',quarters)

   elif quarters ==1:

       print('quarter: ',quarters)

   if dimes >1:

       print('dimes: ',dimes)

   elif dimes ==1:

       print('dime: ',dimes)

   if nickels >1:

       print('nickels: ',nickels)

   elif nickels ==1:

       print('nickel: ',nickels)

   if pennies >1:

       print('pennies: ',pennies)

   elif pennies ==1:

       print('penny: ',pennies)

#calls the FewestCoinVals() function        

FewestCoinVals()

                     

Explanation:

The program prompts the user to enter change amount in pennies and has int() function to convert input value to integer.  If the value entered is less than or equal to 0 it displays message "no change", otherwise it converts the value using fewest coins. The formulas for converting to each type is given in the code. It uses if and elif statements to check if the final value of total_change has singular or plural coin names such as penny or pennies. The program along with output is attached as the screen shot.

You might be interested in
Olivia started working last year. By April 15th, she will need to prepare and send the Federal government _____.
omeli [17]
Income tax documents
5 0
3 years ago
Read 2 more answers
WILL GIVE BRAINLIEST!!!!!!!!
lord [1]
True,

This is a true statement, pipeline construction is taken very seriously and heavily regulated by multiple entities.
TRUE
6 0
3 years ago
What tool allows you to search external competitive intelligence research?
enot [183]

Answer:

SocialPeta

Explanation:

4 0
2 years ago
This week you will learn about basic code structure. The term structure, as it relates to programming, refers to the decisions y
GenaCL600 [577]
Instead of having to write multiple pieces of code for different outcomes, you can use an elseif statement and make your code easier to read and easier to understand.
8 0
4 years ago
Wat is a computer risk<br>​
klemol [59]

Answer:

Virus, cyber theft

Explanation:

A computer risk is something that can potentially harm your data on your computer or harm you through a computer by using theft tactics from real people to autonomous viruses making it to your computer and slowing your computer. With cybrrtheft thieves can get personal info through accounts to pictures and payment information.

4 0
4 years ago
Read 2 more answers
Other questions:
  • T<br> F<br> 5.<br> You can save presentations in PDF and XPS formats.
    14·1 answer
  • Subnetting is accomplished by borrowing bits from the _____ portion of an ip address and reassigning those bits for use as netwo
    13·1 answer
  • Use the variables k and total to write a while loop that computes the sum of the squares of the first 50 counting numbers, and a
    10·1 answer
  • A location in space is called?
    6·2 answers
  • I have a PTCL Router. When I reset it it stops working. So if I backup its settings and use them after reset will my PTCL Work
    13·2 answers
  • Software is the word for:
    15·1 answer
  • Why is the technology so effective in tracking contacts
    7·1 answer
  • PLEASE HELP!
    5·1 answer
  • Silicone rubber and urethane caulks generally give the ____________ overall performance for exterior building envelope applicati
    8·1 answer
  • How are the four characteristics of the db approach related to the four functions of a dbms?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!