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
19. When cells or rows are inserted or deleted in an Excel worksheet, how are cell references affected by the insertion or delet
kramer
<span>A) Cell references are not affected.</span>
6 0
4 years ago
Read 2 more answers
Which is an example of synchronous communication? e-mail voicemail text message telephone conversation
professor190 [17]
Telephone conversation is the answer because the data works off the same clock and the data transfer occurs at regular intervals.
3 0
3 years ago
Read 2 more answers
What is one difference between IDLE and Eclipse?
Stells [14]

Answer:

IDLE is a language-specific IDE, while Eclipse is a multi-language IDE.

Explanation:

IDE or integrated development environment, are programs developed to allow programmers to Code, IDLE is specific software to code in python, has tools to make it easier and to personalize it to your python needs. Eclipse is software with open source that can be used with multiple languages basically Eclipse is a kind of IDE, while IDLE is a specific IDE for python.

5 0
3 years ago
Read 2 more answers
Which of the following is true about database queries?
8_murik_8 [283]

Answer:D

Queries are always saved and can therefore be run on the most up-to-date database information

4 0
3 years ago
In chapter 3, we discussed syntax and semantics, in general there are two types of grammars for programming languages, regular a
WARRIOR [948]

Answer:

Lexical rules that are defined in case of regular grammar are simple and the notation is quite easy to understand.

Regular expression are useful for defining constructs of identifiers or constants. e.g. a|b etc.

In the case of context-free, grammar is not simple and deals with the productions.

Context-free are useful in describing the nested constructs like if-else etc which are not defined by regular expressions.

These produce a higher level of reliability as it provides a medium for generating syntactical as well as semantic data. The grammar is context-free is a little complex.

Explanation:

8 0
3 years ago
Other questions:
  • What is the type of account and normal balance of allowance for uncollectible accounts?
    13·2 answers
  • If someone receives a shock, or a piece of equipment is throwing sparks or arcing you should try to pull them away from the sour
    7·1 answer
  • Sam wants to move from his current role in his organization to a managerial role. Which certification will help him get on a man
    6·1 answer
  • 18. Which type of briefing is delivered to individual resources or crews who are assigned to operational tasks and/or work at or
    14·1 answer
  • The data manipulation language (DML) of SQL contains SELECT, INSERT, DELETE, and UPDATE statements, whereas the data definition
    12·1 answer
  • What is a GUI?
    11·1 answer
  • What are the uses of plotters​
    7·2 answers
  • 3) Prompt the user for a 3-digit number, and the output should be the magical #, which is formed with each digit shifted to the
    13·1 answer
  • The term wiki refers to a(n): Group of answer choices type of short-message blogging, often made via mobile device and designed
    9·1 answer
  • A small company with 100 computers has hired you to install a local area network. All of the users perform functions like email,
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!