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
givi [52]
2 years ago
8

Create a script that will determine how many of each currency type are needed to make change for a given amount of dollar and ce

nts. Input Asks the user for a dollar and cents amount as a single decimal number. Output The program should indicate how many of each of these are needed for the given amount: $20 bills $10 bills $5 bills $1 bills Quarters ($0.25 coin) Dimes ($0.10 coin) Nickels ($0.05 coin) Pennies ($0.01 coin) If a dollar or coin is not needed (its quantity required is 0), do not print it.
Computers and Technology
1 answer:
Fantom [35]2 years ago
8 0

Answer:

The program in Python is as follows:

dollar = float(input("Dollars: "))

t20bill = int(dollar//20)

dollar -= t20bill * 20

t10bill = int(dollar//10)

dollar -= t10bill * 10

t5bill = int(dollar//5)

dollar -= t5bill * 5

t1bill = int(dollar//1)

dollar-= t1bill * 1

qtr = int(dollar//0.25)

dollar -= qtr * 0.25

dime = int(dollar//0.10)

dollar -= dime * 0.10

nkl = int(dollar//0.05)

dollar -= nkl * 0.05

pny = round(dollar/0.01)

if t20bill != 0:    print(t20bill,"$20 bills")

if t10bill != 0:    print(t10bill,"$10 bills")

if t5bill != 0:    print(t5bill,"$5 bills")

if t1bill != 0:    print(t1bill,"$1 bills")

if qtr != 0:    print(qtr,"quarters")

if dime != 0:    print(dime,"dimes")

if nkl != 0:    print(nkl,"nickels")

if pny != 0:    print(pny,"pennies")

Explanation:

This gets input for dollars

dollar = float(input("Dollars: "))

Calculate the number of $20 bills

t20bill = int(dollar//20)

Calculate the remaining dollars

dollar -= t20bill * 20

Calculate the number of $10 bills

t10bill = int(dollar//10)

Calculate the remaining dollars

dollar -= t10bill * 10

Calculate the number of $5 bills

t5bill = int(dollar//5)

Calculate the remaining dollars

dollar -= t5bill * 5

Calculate the number of $1 bills

t1bill = int(dollar//1)

Calculate the remaining dollars

dollar-= t1bill * 1

Calculate the number of quarter coins

qtr = int(dollar//0.25)

Calculate the remaining dollars

dollar -= qtr * 0.25

Calculate the number of dime coins

dime = int(dollar//0.10)

Calculate the remaining dollars

dollar -= dime * 0.10

Calculate the number of nickel coins

nkl = int(dollar//0.05)

Calculate the remaining dollars

dollar -= nkl * 0.05

Calculate the number of penny coins

pny = round(dollar/0.01)

The following print the number of bills or coins. The if statement is used to prevent printing of 0

<em>if t20bill != 0:    print(t20bill,"$20 bills")</em>

<em>if t10bill != 0:    print(t10bill,"$10 bills")</em>

<em>if t5bill != 0:    print(t5bill,"$5 bills")</em>

<em>if t1bill != 0:    print(t1bill,"$1 bills")</em>

<em>if qtr != 0:    print(qtr,"quarters")</em>

<em>if dime != 0:    print(dime,"dimes")</em>

<em>if nkl != 0:    print(nkl,"nickels")</em>

<em>if pny != 0:    print(pny,"pennies")</em>

You might be interested in
Describe the procedure for creating a table or spreadsheet in a presentation slide.
brilliants [131]
<span>Select the slide that you want to insert a table on.On the Insert tab, in the Tables group, click Table, and then click Excel Spreadsheet.<span>To add text to a table cell, click the cell, and then enter your text</span></span>
5 0
3 years ago
What is looping in QBASIC​
Elden [556K]

A looping is a set of instructions which is repeated a certain number of times until a condition is met. hlo dai k xa halkhabar

3 0
3 years ago
Which of the following describes colors, spacing, borders, and other effects that change the appearance of a table?
lisabon 2012 [21]
It is the table style that describes colors and spacing borders and other effects that change the appearance of the table
5 0
3 years ago
Help!!!
Butoxors [25]

Answer:

ummmm try the inequality protragathron theorum

Explanation:

ok

3 0
3 years ago
This Command to insert copied text anywhere in your document
harina [27]

Answer:

Paste

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • In what year did commercial use of the Internet become available? 1991 1996 1999 2001
    9·1 answer
  • Write a program that prints the number 1 through 10 using a while loop
    6·1 answer
  • What is the film format that many filmmakers feel is superior to any other format?
    13·1 answer
  • Company-wide systems that connect one or more local area networks (LANs) or wide area networks (WANs) are called _____. a) legac
    15·1 answer
  • Matt is a senior developer for Cyber Protect, a company that helps secure management information systems. Matt's new task is to
    8·1 answer
  • Given that Apache and Internet Information Services (IIS) are the two most popular web application servers for Linux and Microso
    10·1 answer
  • The pinky finger on the right hand types _____.
    15·2 answers
  • I want to start a debate about something
    9·2 answers
  • This seems like a good time to ask the basic question, “How’s it going in class?” Feel free to offer constructive feedback about
    6·2 answers
  • Is each of the following method identifiers (a) legal and conventional, (b) legal but unconventional, or (C) illegal?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!