I am stuck trying to create a program in PYTHON that calculates the coins needed to make change for a specified US monetary amount.Here is the code I have so far# Module 3 Change Calculator# Program is to take a given dollar amount, and convert it into coinsdollar_amount = 1##quarters = .25##dimes = .1##nickels = .5##pennies = 01print("Enter dollar amount (for example, .56, 7.85): ")dollar_amount = inputif dollar_amount < 0:print("Error, dollar amount must be positive.")else:quarters = dollar_amount // 25dimes = (dollar_amount % 25) // 10nickels = dollar_amount % 25 % 10 // 5pennies = dollar_amount % 5print("The number of coins for ", dollar_amount, "dollars are: "print("Quarters: + , quarters")print("Dimes:" +, dimes)print("Nickels: " +, nickels)print("Pennies: " +, pennies)

Question

I am stuck trying to create a program in PYTHON that calculates the coins needed to make change for a specified US monetary amount.

Here is the code I have so far

# Module 3 Change Calculator
# Program is to take a given dollar amount, and convert it into coins

dollar_amount = 1
##quarters = .25
##dimes = .1
##nickels = .5
##pennies = 01

print("Enter dollar amount (for example, .56, 7.85): ")

dollar_amount = input

if dollar_amount < 0:
print("Error, dollar amount must be positive.")
else:
quarters = dollar_amount // 25
dimes = (dollar_amount % 25) // 10
nickels = dollar_amount % 25 % 10 // 5
pennies = dollar_amount % 5

print("The number of coins for ", dollar_amount, "dollars are: "
print("Quarters: + , quarters")
print("Dimes:" +, dimes)
print("Nickels: " +, nickels)
print("Pennies: " +, pennies)

Expert Answer

2 Ratings

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: AskForNumbers Declare an integer array locally with the size of 200. Create a program that asks the ...

A: In order to implement the question mentions a method called getChoice() information about which has ...

Q: do big data could replace the artistic vision of a creative director? and why?

A: Justification:“Yes”, big data replace the artistic vision of a creative director.

Q: Construct an npda corresponding to the grammar S→aABB|aAA,A→aBB|b,B→bBB|A.

A: Firstly, we will convert the given grammar into GNFS → aABB|aAAA → aBB|bB → bBB|aBB|a

Q: • Write a program in Eclipse that computes future investment value at a given interest rate for a sp...

A: Program plan:Import necessary packages.Define a class named “Investment”.Define a method named “comp...

Q: Prove that the following languages are not regular: (b) L = {anblak : k ≠ n + l}.

A: First, assume the given language is regular.Then apply pumping lemma to prove the statement is not r...

Q: Draw a half-adder using only NAND gates.

A: Half adder is basically a combinational circuit which executes simple basic addition of two binary n...

Q: Problem Description: The international standard letter/number mapping found on the telephone keypad ...

A: The pseudocode is as follows:Prompt user for a letter in upper caseReceive the input.Convert the use...

Q: Assume that you have been tasked by your employer to develop an incident response plan. Create a lis...

A: Stakeholder:A stakeholder can be a person, a group, or an organization that has an affair or matter ...

Q: Write a grammar for the language consisting of strings built only of theletters aand b. The strings ...

A: The given language L contains the strings that have infinite number of letters but the strings must ...

Q: Design a payroll program that prompts user enter an employee's hourly pay rate and the number of hou...

A: Since nothing is mentioned about the programming language to be used, Java has been used as it is on...

Q: Hello, I have a question with the program javascript and in the program I need to create a timer in ...

A: To display the greeting message, we can declare a new variable, suppose wish, to store the greeting ...

Q: Let L1 = L (a∗baa∗) and L2 = L (aba∗). Find L1/L2.

A: Solution:Given that,Input: L1= L(a*baa*) and L2 = L(aba*) Output: Determine the L1/L2.We take all st...

Q: Find regular grammars for the following languages on {a, b}: L = {w : na (w) and nb (w) are both eve...

A: Regular grammar for the language L = {W: na (w) and nb (w) are both even} is as follows:

Q: Develop the ‘Shape’ application such that: ‘Rectangle’, ‘Ellipse’, and ‘Triangle’ classes inherit f...

A: Program plan:Define a class named “Shape”.Define a default constructor to print constructor invoked ...

Q: 3. Which command can you use to look for the file names status.report? Which command can you use to ...

A: The command used to look for files is ‘find’ command. Find command can be used with many criteria to...

Q: create a file in c++. Download the attached CreateRandomNumbersFile.cpp file, open it in Dev C++, an...

A: Program Instructions:Include necessary header files, declare local variables, and display a hello me...

Q: Question: Write a function to display a pattern as follows: 1 2       1 ... ... n       n-1         ...

A: Solution:The python program has the following algorithm:In the displayPattern() function,Declare and...

Q: Write a class AnalyzeNumbers which asks the user to enter the number of inputs andstores them in an ...

A: Program plan:Define the class “AnalyzeNumbers”.Define the “main()” method.Create object for “Scanner...

Q: The following print code is to find out the ASCII code, character for the decimal codes,and comparis...

A: ASCII chart is shown on the board

Q: Assume the following declarations and initializations (MIN, MAX, num) are made just before each sub-...

A: Answer: Algorithm:The program has the following algorithm:The class name is “Main” and in the main m...

Q: Function #1: superman Parameters: height - an integer representing the user's height in inches Descr...

A: Solution:Superman() function:#Define the functiondef superman(input_inches):    #Declare the variabl...

Q: 21,22,23

A: An image contains white, black or different shades of grey from black (maximum gray) to white (minim...

Q: Problem: Create a base class called Vehicle that has the manufacturer’s name (typeString), number of...

A: Program plan:Create a class called “Person” with required constructors and methods.Create a class ca...

Q: Cosc 1337 java Perform program setup and initializations- Prompt the user and input the starting Cel...

A: Note: The given program is compiled and executed in "NetBeans IDE"

Q: Consider the following procedure: procedure mystery (x, y, z); integer x, y, z;beginz =2; y = z + x;...

A: Call by reference The arguments passed to a function will copy the address of an argument into the f...

Q: As an IT manager, what strategy would you have followed to avoid the failed implementation of ERP sy...

A: ERP system:It denotes software for business process management that permits an organization in using...

Q: I am trying to write a program to convert an integer to a hexadecimal. How do I do this without us...

A: As there is no particular programming language mentioned, we are doing this conversion of integer nu...

Q: I need help with creating a main.css, I already have the HTML.the details are in the pic and I will ...

A: You can use following code in your main.css file to format your HTML document.Note: Make use of &lt;...

Q: How do I call a function in Python from another module without using import *?

A: Statement used to call a function in python from another module without using import * statement is ...

Q: 2. What are ‘accelerated filers’ and how are they selected- revenue, # employee, etc.

A: If a company meets the following conditions at the fiscal year end, it is considered as accelerated ...

Q: how to put a picture to top right corner in HTML

A: HTML stands for Hypertext markup language and is mainly used to format web pages and web sites. Html...

Q: write a program in c++. You work for a box company, and have been asked to write a program to compar...

A: Solution:The C++ program has the following algorithm:Declare and initialize the required variables.D...

Q: create a new file in c++. In this lab, you will add some more functionality to the program. Use loop...

A: Program Instructions:Declare variables and write a welcome message.Always convert the user's choice ...

Q: 12 4x)x,is an another form of representation of fuzzy set. A, (x) /x, is an another form of represen...

A: A fuzzy set is a pair X, m(A)) where X is a Universal set and mA) is a membership function or degree...

Q: Write a PL/SQL block to accept a date from the user and print the day and the date as shown below. U...

A: Solution:Given data,The PL/SQL code read the user input of date and display the day and the date in ...

Q: You are not required to execute the queries. However, your syntax must by accurate.You must give at ...

A: SELECT Movie_Tiltle, Movie_Year, Price_Description, Rental_Fee FROM Movies WHERE Categories = ‘famil...

Q: What language is accepted by the Turing machine whose transition graph is in the figure below?

A: Turing machine:Turing machine is a model of a hypothetical computing machine which can use a predefi...

Q: For this program you need to use Eclipse. Carefully read the instructions and write a program that r...

A: The program has the following algorithm: Step 1: Create object for “Scanner” class to read the user ...

Q: (The Fan class) Design a class named Fan to represent a fan. The class contains:■ Three constants na...

A: Java program to create Fan class is as follows:

Q: 1.6 Compute the scalar cardinality and the fuzzy cardinality for each of thefollowing fuzzy set.

A: The scalar cardinality of a fuzzy set is calculated using the formula:

Q: Assume that an array of integers named a that contains exactly five elements has been declared and i...

A: Didn’t mention which language to do the problem. So, did the problem in Java.Given:Let assume an arr...

Q: 5-13) Find the largest n such that n cubed is less than a positive integer entered by the user. Use ...

A: The heart of the algorithm lies in finding such a number whose cube is less than the given number he...

Q: I am struggling on storing numbers from the getChoice () function into an array and pulling it back ...

A: Click to see the answer

Q: On its own, the number 190 is an example of:

A: On its own, the number 190 is a decimal number.

Q: Exhibit an algorithm to determine whether or not a regular language L contains any string w such tha...

A: Solution: Given that,The following algorithm identify whether or not a regular language “L” contains...

Q: Transform the grammar S → aSaaA|A, A → abA|bb into Chomsky normal form.

A:  For solving your problem , first of all we will discuss about  algorithm to convert grammar into  C...

Q: Find context-free grammars for the following languages (with n ≥ 0, m ≥ 0, k ≥ 0):  L = {anbmck, k =...

A: Solution:Given language,L = {anbmck, k = n+m}Consider the “G” as grammar production is given below:

Q: what are some of the challenges that can face a firm to combine “a clear brand vision with a common ...

A: Introduction:The combination of clear brand vision of an organization with a common operating model ...

Q: Write a complete C++ program that randomly generates 20 integers between the rangeof 1 to 50 and sto...

A: The random number is generated by using rand() function from stdlib.h and in order to generate a new...

Q: How can I create a decoder and a multiplexer in a circuit? The decoder has a 3 bit select input and ...

A: A decoder is a circuit which has n inputs and 2n outputs. So if there are 3 inputs to a decoder it w...