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
Effectus [21]
3 years ago
13

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

r 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. The input should be an integer, with the unit as "cents". For example, the input of 126 refers to 126 cents. 1 Dollar = 100 cents 1 Quarter = 25 cents 1 Dime = 10 cents 1 Nickel = 5 cents 1 Penny = 1 cent Ex: If the input is:
Computers and Technology
1 answer:
riadik2000 [5.3K]3 years ago
4 0

Answer:

In Python:

cents = int(input("Cents: "))

dollars = int(cents/100)

quarters = int((cents - 100*dollars)/25)

dimes = int((cents - 100*dollars- 25*quarters)/10)

nickels = int((cents - 100*dollars- 25*quarters-10*dimes)/5)

pennies = cents - 100*dollars- 25*quarters-10*dimes-5*nickels

if not(dollars == 0):

   if dollars > 1:

       print(str(dollars)+" dollars")

   else:

       print(str(dollars)+" dollar")

if not(quarters == 0):

   if quarters > 1:

       print(str(quarters)+" quarters")

   else:

       print(str(quarters)+" quarter")

if not(dimes == 0):

   if dimes > 1:

       print(str(dimes)+" dimes")

   else:

       print(str(dimes)+" dime")

if not(nickels == 0):

   if nickels > 1:

       print(str(nickels)+" nickels")

   else:

       print(str(nickels)+" nickel")

if not(pennies == 0):

   if pennies > 1:

       print(str(pennies)+" pennies")

   else:

       print(str(pennies)+" penny")

   

Explanation:

A prompt to input amount in cents

cents = int(input("Cents: "))

Convert cents to dollars

dollars = int(cents/100)

Convert the remaining cents to quarters

quarters = int((cents - 100*dollars)/25)

Convert the remaining cents to dimes

dimes = int((cents - 100*dollars- 25*quarters)/10)

Convert the remaining cents to nickels

nickels = int((cents - 100*dollars- 25*quarters-10*dimes)/5)

Convert the remaining cents to pennies

pennies = cents - 100*dollars- 25*quarters-10*dimes-5*nickels

This checks if dollars is not 0

<em>if not(dollars == 0):</em>

If greater than 1, it prints dollars (plural)

<em>    if dollars > 1:</em>

<em>        print(str(dollars)+" dollars")</em>

Otherwise, prints dollar (singular)

<em>    else:</em>

<em>        print(str(dollars)+" dollar")</em>

This checks if quarters is not 0

<em>if not(quarters == 0):</em>

If greater than 1, it prints quarters (plural)

<em>    if quarters > 1:</em>

<em>        print(str(quarters)+" quarters")</em>

Otherwise, prints quarter (singular)

<em>    else:</em>

<em>        print(str(quarters)+" quarter")</em>

This checks if dimes is not 0

<em>if not(dimes == 0):</em>

If greater than 1, it prints dimes (plural)

<em>    if dimes > 1:</em>

<em>        print(str(dimes)+" dimes")</em>

Otherwise, prints dime (singular)

<em>    else:</em>

<em>        print(str(dimes)+" dime")</em>

This checks if nickels is not 0

<em>if not(nickels == 0):</em>

If greater than 1, it prints nickels (plural)

<em>    if nickels > 1:</em>

<em>        print(str(nickels)+" nickels")</em>

Otherwise, prints nickel (singular)

<em>    else:</em>

<em>        print(str(nickels)+" nickel")</em>

This checks if pennies is not 0

<em>if not(pennies == 0):</em>

If greater than 1, it prints pennies (plural)

<em>    if pennies > 1:</em>

<em>        print(str(pennies)+" pennies")</em>

Otherwise, prints penny (singular)

<em>    else:</em>

<em>        print(str(pennies)+" penny")</em>

<em>    </em>

You might be interested in
You have a desktop computer that supports both IEEE 1394 and USB 2.0. You are purchasing some devices that will connect to these
zimovet [89]

Answer:

IEEE 1394 supports more devices on a single bus

Explanation:

What this means is that IEEE 1394 provides a single plug-and-socket connection on which up to 63 devices can be attached with data transfer speeds up to 400 Mbps (megabit s per second). The standard describes a serial bus( A shared channel that transmits data one bit after the other over a single wire or fiber) or pathway between one or more peripheral devices and your computer's microprocessor .

7 0
4 years ago
Which of the following is the correct code to link the text "Sunny Days" to the website www.sunnysunshine.com?
coldgirl [10]

All of the above. <em><u>They're</u></em><em><u> </u></em><em><u>all</u></em><em><u> </u></em><em><u>the</u></em><em><u> </u></em><em><u>same</u></em><em><u>.</u></em>

3 0
4 years ago
Write the following abbreviations in full next to the question number
kow [346]

Answer:

<u>1.2.1 CPU</u>

Central Processing Unit

<u>1.2.2 RAM</u>

Random Access Memory

<u>1.2.3 HDD</u>

Hard Disk Drive

<u>1.2.4 MB</u>

Megabyte

<u>1.2.5 OS</u>

Operating System

<em>Hope this helps! ^-^</em>

<em>-Isa </em>

7 0
3 years ago
Which function of InfoSec management encompasses security personnel as well as aspects of the SETA program?
inessss [21]

Answer:

People

Explanation:

Information security management provides a description of the controls needed by an organization in order to ensure that it is capable of protecting the integrity, availability, and confidentiality of assets from security vulnerability and threats. On the other hand, the SETA program is three phased and ensures that organizations address and implement training and techniques for information security. Hence the only function that encompasses security personnel as well as aspects of the SETA program is the People function.

8 0
4 years ago
You are contacted by a project organizer for a university computer science fair. The project organizer asks you to hold a forum
Usimov [2.4K]

Answer:

Note this:

Nothing beats an open market community!

See below the explanations.

Explanation:

Linux Operating system was created in the early 1990s by Finnish software engineer "Linus Torvalds" and the Free Software Foundation.

1. Why choose Linux over windows.

2. Linux strength.

3. Linux concept.

3 0
4 years ago
Other questions:
  • Power point 2016 which chart element provides the boundaries of the graphic?
    6·1 answer
  • Jamie works on a spread sheet in which he has to label stes of data. How can he navigate between the cells in the spread sheet
    8·1 answer
  • You need to write a loop that will repeat exactly 125 times. which is the preferred loop construct to use?
    12·1 answer
  • 6. Data are given in comma delimited text file for a toy rocket. The rocket is powered by pressurized water that is discharged f
    14·1 answer
  • ____ is a programming language used to view and manipulate data that is stored in a database.
    6·1 answer
  • Speed is how fast an object moves a certain distance within a length of time. How is speed calculated?
    14·2 answers
  • The scope of a variable declared inside of a function is:
    8·1 answer
  • You work on a team whose job is to understand the most sought after toys for the holiday season. A teammate of yours has built a
    11·1 answer
  • An error in the sequence of words or rules in a program that prevents the program from running is what?
    10·2 answers
  • All of the following are properties of a relation except __________.Group of answer choicesThe order of tuples (rows) is not sig
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!