Write a program with the total change amount 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. 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:

Answers

Answer 1

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

if not(dollars == 0):

If greater than 1, it prints dollars (plural)

   if dollars > 1:

       print(str(dollars)+" dollars")

Otherwise, prints dollar (singular)

   else:

       print(str(dollars)+" dollar")

This checks if quarters is not 0

if not(quarters == 0):

If greater than 1, it prints quarters (plural)

   if quarters > 1:

       print(str(quarters)+" quarters")

Otherwise, prints quarter (singular)

   else:

       print(str(quarters)+" quarter")

This checks if dimes is not 0

if not(dimes == 0):

If greater than 1, it prints dimes (plural)

   if dimes > 1:

       print(str(dimes)+" dimes")

Otherwise, prints dime (singular)

   else:

       print(str(dimes)+" dime")

This checks if nickels is not 0

if not(nickels == 0):

If greater than 1, it prints nickels (plural)

   if nickels > 1:

       print(str(nickels)+" nickels")

Otherwise, prints nickel (singular)

   else:

       print(str(nickels)+" nickel")

This checks if pennies is not 0

if not(pennies == 0):

If greater than 1, it prints pennies (plural)

   if pennies > 1:

       print(str(pennies)+" pennies")

Otherwise, prints penny (singular)

   else:

       print(str(pennies)+" penny")

   


Related Questions

Write VHDL code for the circuit corresponding to an 8-bit Carry Lookahead Adder (CLA) using structural VHDL (port maps). (To be completed before your lab session.)

Answers

Answer:

perdo si la pusiera es español te ayudo pero no esta en español

whats this oh _____
what is it
A) jane
B) juan.
C)juan
D) horse

Answers

Answer:

juan duhhhhh hehehe

Explanation:

The ABC box company makes square puzzle cubes that measure 4 inches along each edge. They shipped the cubes in a box 8 in x 12 in x 16 in. How many cubes can they ship in the box?

Answers

Answer: They can ship 32 puzzle cubes in the box.

Explanation: So the volume of each puzzle cubes = side³

=(4)³ cubic inches.

Then the volume of the box is= (8×12×16) cubic inches.

(8×12×16)/4^3= 32

Write a class called Dragon. A Dragon should have a name, a level, and a boolean variable, canBreatheFire, indicating whether or not the dragon can breathe fire. The class should have getter methods for all of these variables - getName, getLevel, and isFireBreather, respectively.

Answers

Answer: A dragon name could be name Holls and at level 14 and can breathe fire

Explanation:

Other Questions
Which of the following statement is not true? a. Exposure to electromagnetic fields is known to cause leukemia. b. Excessive exposure to asbestos can lead to asbestosis. c.Excessive exposure to radiations can cause health problems including cancer. d. Any sound above 80 dB is potentially dangerous. What is the subject of the poem?O being a nobodyO being part of a pairO being importantO being friends Complete the analogy. carpenter is to hammer as dentist is to drill patient mouth Submit Please help me!!Which pair of lines gives an example of end rhyme?A. We flash and crashacross the mudB. My hat is in tattersand nothing else mattersC. Alone and in sorrowtomorrow we departD. Wee Wendy Windywent out for a walk In Ancient Egypt the Pharaoh had authority because he was considered to be a living incarnation of a god. Because of this, their government was structured around their religious beliefs. What type of government is this? The length of a rectangular frame is 4 inches longer than twice the width. If the perimeter is 38 inches, find the dimensions of the frame.WILL GIVE WHOEVER ANSWERS BRAINIEST Mark said he can decompose five six into three fractions with three different numerators and the same denominator is this possible explain What was discovered in Georgia that became the impetus for the violation of the Worcester v Georgia treaty? To be considered part of a market, an individual must Does it mean that we have learned from the past? Does itmean that society has changed? Has the human beingbecome less indifferent and more human? Have we reallylearned from our experiences? Are we less insensitive tothe plight of victims of ethnic cleansing and other forms ofinjustices in places near and far? Is today's justifiedintervention in Kosovo, led by you, Mr. President, a lastingwarning that never again will the deportation, theterrorization of children and their parents, be allowedanywhere in the world? Will it discourage other dictators inother lands to do the same?Why does Wiesel end his speech with several questions?A. To provide a strong, religious plea for helpB. To provide the audience with a warm, comfortable feeling at theend of the speechC. To leave unanswered questions for the audience to think aboutD. To directly state his opinion Recently you and some of your class were chosen to take part in a festival your principal is very pleased that you took part at the festival. (article writing) What group of organisms is found at the base of every energypyramid? given y= 1/3x+5, find y when x = -3 Why do you think many countries have free elementary school education as a human right? Hi! My teacher shows us a video and thats it, so I'm really struggling on our math test today. Can you help me answer this question? Thank you :) Which two foods should a food handler never handle with bare hands? Simplify to find the quotients . 24. ) (a ^ 8)/(a ^ 3) IIIMULTIPLE CHOICE QUESTIONHow was Christianity used as a justification for imperialism? Can someone help me with this? (ill be asking more of these questions soon) Suppose you know that a company's stock currently sells for $57 per share and the required return on the stock is 10.4%. You also know that the total return on the stock is evenly divided between capital gains yield and dividend yield. If it's the company's policy to always maintain a constant growth rate in its dividends, what is the current dividend per share? What is the dividend per share in Year 4?