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
Gnoma [55]
2 years ago
11

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

ne. The coin types are dollars, quarters, dimes, nickels, and pennies. Use singular and plural coin names as appropriate, like 1 penny vs. 2 pennies. If the input is 0 or less, output: no change. If the input is 45, the output is:
1 quarter 2 dimes
Computers and Technology
1 answer:
Contact [7]2 years ago
3 0

Answer:

The program in python programming language is as follows

amount = int(input("Enter Amount:  "))

#Check if input is less than 1

if amount<=0:

     print("No Change")

else: #If otherwise

     #Convert amount to various coins

     dollar = int(amount/100) #Convert to dollar

     amount = amount % 100 #Get remainder after conversion

     quarter = int(amount/25) #Convert to quarters

     amount = amount % 25 #Get remainder after conversion

     dime = int(amount/10) #Convert to dimes

     amount = amount % 10 #Get remainder after conversion

     nickel = int(amount/5) #Convert to nickel

     penny = amount % 5 #Get remainder after conversion

     #Print results

     if dollar >= 1:

           if dollar == 1:

                 print(str(dollar)+" dollar")

           else:

                 print(str(dollar)+" dollars")

     if quarter >= 1:

           if quarter == 1:

                 print(str(quarter)+" quarter")

           else:

                 print(str(quarter)+" quarters")

     if dime >= 1:

           if dime == 1:

                 print(str(dime)+" dime")

           else:

                 print(str(dime)+" dimes")

     if nickel >= 1:

           if nickel == 1:

                 print(str(nickel)+" nickel")

           else:

                 print(str(nickel)+" nickels")

     if penny >= 1:

           if penny == 1:

                 print(str(penny)+" penny")

           else:

                 print(str(penny)+" pennies")

Explanation:

The program is written in python programming language and it uses comments to explain some lines

Variable amount is declared as integer

Line 3 checks if amount is less than or equal to 0

If yes, the program outputs No Change

Else, it converts the input amount to lesser coins

Line 7 of the program gets the dollar equivalent of the input amount

Line 8 gets the remainder

Line 9 gets the quarter equivalent of the remainder

Line 10 gets the remainder

Line 11 gets the dime equivalent of the remainder

Line 12 gets the remainder

Line 13 gets the nickel equivalent of the remainder

Line 14 gets the penny equivalent of the remainder

Line 16 till the end of the program prints the output and it uses appropriates name (singular and plural)

You might be interested in
Without a well-designed, accurate database, executives, managers, and others do not have access to the ____________________ they
ohaa [14]

Answer:

Information

Explanation:

Good decisions are normally based on facts which are tangible information that can be analysed to show trends of key figures such as sales, income, production that are so critical in business. A well-designed and accurate database captures and stores these figures in an organised way which will enable the information or data to be analysed to make informed decisions.

6 0
2 years ago
Easy coding question, please help.
borishaifa [10]

Answers:

What is the index of the last element in the array? stArr1.length()-1

This prints the names in order. How would I print every other value? Change line 4 to: index = index +2

Change line 7 to: i < names.length

5 0
2 years ago
O How basic blocks are identified and how the blocks are used to construct control flow graphs
OLEGan [10]

Basic blocks are identified  because they are known to be a straight line that is known also as a code sequence that tends to have no branches in regards to its in and out branches and its exception is only to the entry and at the end.

Note that  Basic Block is said to be a composition  of statements that is known to be one that often always executes one after other, and this is often done in a sequence.

<h3>How do you create a flow graph from the basic blocks?</h3>

Flow graph  is gotten by:

  • Lets Block B1 be the initial node and also Block B2 will tend to follows B1, so from B2 to B1 there is seen a kind of an edge.

Note that the first task is for a person to partition a sequence of three-address code and this is done into basic blocks.

Hence, Basic blocks are identified  because they are known to be a straight line that is known also as a code sequence that tends to have no branches in regards to its in and out branches and its exception is only to the entry and at the end.

Learn more about basic blocks from

brainly.com/question/132319

#SPJ1

5 0
1 year ago
In what ways can information be slanted in a news report?
ratelena [41]

Answer:It all depends on who the reader is likely to be and the information they’ll want.

Explanation:

Newspaper 1: Company wins contract

Newspaper 2: Previous company loses contract (equally true)

Newspaper 3, say a student paper in the local town: Prospects for new jobs open up as company wins contract.

8 0
1 year ago
A loop that will output only the names that come before "Thor" in the alphabet from the names list.
matrenka [14]

names = ["Kevin", "Joe", "Thor", "Adam", "Zoe"]

names.sort()

for x in names:

   if x == "Thor":

       break

   else:

       print(x)

I made up my own names for the sake of testing my code. I wrote my code in python 3.8. I hope this helps.

3 0
2 years ago
Other questions:
  • Help me on this question
    14·1 answer
  • Which of the following should you NOT do when using CSS3 properties to create text columns for an article element? a. make the c
    12·2 answers
  • Nuclear batteries use devices called thermocouples, which convert the ____ of a nuclear reaction into electricity.
    9·1 answer
  • If your internet were to go out, what steps would you take to troubleshoot to restore your service?
    15·1 answer
  • Knowing the meaning of the acronym WAS I WHY can be most helpful to you when you?
    14·1 answer
  • Apps are designed by___.
    11·2 answers
  • In the list [0, 13, 5.4, "integer"], which element is at index 2?
    11·1 answer
  • Hello. I have an app which doesn't let me get in. It says: "wrong app info". I'm in a samsung device. How can I solve that probl
    13·2 answers
  • Risk taker positive or negative​
    8·1 answer
  • The data _____ component of a database management system (DBMS) is used to create and maintain the data dictionary.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!