answer.
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
ikadub
2 months 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:
zubka84 [1K]2 months ago
3 0

Answer:

The following program is written in python programming language:

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

#Check if the input is less than 1

if amount<=0:

print("No Change")

else: #If input is valid

#Convert input into different coins

dollar = int(amount/100) #Dollar conversion

amount = amount % 100 #Calculate remainder

quarter = int(amount/25) #Quarter conversion

amount = amount % 25 #Calculate remainder

dime = int(amount/10) #Dime conversion

amount = amount % 10 #Calculate remainder

nickel = int(amount/5) #Nickel conversion

penny = amount % 5 #Calculate remainder

#Display 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 implemented using python and includes comments for clarification.

The variable amount is defined as an integer.

The check in line 3 determines if the amount is less than or equal to 0.

If it is, "No Change" is printed.

If not, it converts the entered amount into smaller coins.

Line 7 converts the input amount to its dollar counterpart.

Line 8 calculates the remainder.

Line 9 converts the remainder to quarters.

Line 10 calculates the new remainder.

Line 11 converts the current remainder to dimes.

Line 12 calculates the adjusted remainder.

Line 13 calculates the nickel equivalent.

Line 14 gets the penny equivalent of what's left.

Lines 16 and beyond display the result using the correct terminology (singular or plural).

You might be interested in
Sophie often makes grammatical errors in her document. Which feature of the Spelling and Grammar tool can she use to understand
ivann1987 [1066]

Given that Sophie frequently commits numerous spelling and grammar mistakes in her document, it would be beneficial for her to utilize a function provided by Microsoft Word that assists her in recognizing her errors, which is what (D) Explain accomplishes.

Explain would indicate to Sophie the portions of her sentences that are incorrect, the words that were mistyped, and offer suggestions for better phrasing to prevent fragmented sentences.

8 0
2 months ago
Read 2 more answers
Your computer science teacher asks you to sample a black and white image that is 4" x 6". How would you sample the image to prov
8_murik_8 [964]

Answer:

The maximum dimensions possible for an image using the pixelation widget are 255 by 255 pixels.

When an image undergoes resizing, its pixel count may either increase or decrease, resulting in resampling. This process alters the overall file size.

Explanation: This is all the information I could gather. I hope it's useful. Sorry.

3 0
3 months ago
Which is among the earliest formats of audio used in video games? A. MP3 B. wave table synthesis C. pulse code modulation D. MOD
Harlamova29_29 [1022]

Answer:

MOD

Explanation:

The MOD audio file format is primarily designed to represent musical content. It employs the.MOD file extension and is notably recognized as background music in various independent video games. It can be said that MOD audio file types are among the most widely used trackers in numerous computer games and demos.

0 0
2 months ago
Read 2 more answers
When long labels are required, which of these commands can you use to improve readability of a worksheet?
maria [1035]
I think it's text wrapping! I hope this assists you.
6 0
1 month ago
Read 2 more answers
A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output i
ivann1987 [1066]

Response:

steps = int(input("Specify the number of steps: "))

miles = steps / 2000

print('{:.2f}'.format(miles))

Explanation:

Prompt the user to input the number of steps and convert the input to an integer.

Compute the corresponding miles by dividing the number of steps by 2000.

Output the miles formatted to two decimal places.

5 0
3 months ago
Other questions:
  • Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
    12·1 answer
  • Define a function print_feet_inch_short(), with parameters num_feet and num_inches, that prints using ' and " shorthand. End wit
    6·2 answers
  • What are the differences between a policy, a standard, and a practice? What are the three types of security policies? Where woul
    15·1 answer
  • Any software or program that comes in many forms and is designed to disrupt the normal operation of a computer by allowing an un
    13·1 answer
  • Write a program that prompts the user for an integer, then asks the user to enter that many values. Store these values in an arr
    14·1 answer
  • The principal that users have access to only network resources when an administrator explicitly grants them is called __________
    6·1 answer
  • Which of the following is NOT true about data?
    8·2 answers
  • The engineering firm you work for is submitting a proposal to create an amphitheater at a state park. Proposals must be submitte
    15·1 answer
  • Flowgorithm, Design a program that prompts the user to enter a number within the range of 1 through 10. The program should displ
    8·1 answer
  • _______________ is used by a hacker to mask intrusion and obtain administrator permissions to a computer.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!