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
Write a function:
Elden [556K]

Answer:

what are the choices

:"

Explanation:

5 0
2 years ago
Write a program that asks the user for three names, then prints the names in reverse order.
sasho [114]

Answer:

The program written in C++ is as follows'

#include<iostream>

using namespace std;

int main()

{

string names[3];

cout<<"Please enter three names: "<<endl;

for (int i = 0; i< 3;i++)

{

cin>>names[i];

}

for (int i = 2; i>= 0;i--)

{

cout<<names[i]<<endl;

}

return 0;

}

Explanation:

This line declares an array for 3 elements

string names[3];

This line prompts user for three names

cout<<"Please enter three names: "<<endl;

This following iteration lets user input the three names

for (int i = 0; i< 3;i++)  {  cin>>names[i];  }

The following iteration prints the three names in reverse order

for (int i = 2; i>= 0;i--)  {  cout<<names[i]<<endl;  }

8 0
2 years ago
Configuring a firewall to ignore all incoming packets that request access to a specific port is known as ____.
Sati [7]

Answer: Logical Point Blocking

Explanation:

4 0
1 year ago
My mom works from home selling her craft work online to people all over the world. She can do this from home because we have acc
postnew [5]
The computer and a device
7 0
3 years ago
Read 2 more answers
Which payment method typically charges the highest interest rates everfi
Valentin [98]
The answer is Payday loans.

Payday loans have the highest interest rates charged compared to credit cards, cashier's checks, and pre-paid cards. This type of loan is unsecured and is short -term. It is often called salary loan, payroll loan, or commonly known as cash advance loan.
8 0
2 years ago
Other questions:
  • A company decides to create static design diagrams for an upcoming project. Which statement correctly describes the attribute of
    6·1 answer
  • Which is a function of network media?
    11·2 answers
  • The ____ cell on the worksheet is the one into which you can enter data.â
    15·2 answers
  • What are the first two lines of defense a company should take when addressing security risks?
    10·1 answer
  • Jerry’s managing a Google Search campaign and would like to improve the position in which his ads appear. He’s increased his bid
    15·1 answer
  • A flat-panel detector is exposed with nothing between the x-ray tube and detector. 5 images were acquired on 5 different days us
    6·1 answer
  • At the start of the school year, Brianna’s history teacher announces that students’ final grades will be weighted based on how t
    8·2 answers
  • Im learning about AI in my class and I'm confused about these two questions
    9·2 answers
  • Susan is a network monitoring technician working on a firewall for her company’s network. In the process to determine an open po
    8·1 answer
  • If you do a Find and Replace for a term, where will Word begin looking for the term?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!