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
• what command-line utility can you use to assign the correct dns server ip address
Lilit [14]
On A Windows machine, you can use the netsh command.
<span>netsh interface ip set dns name="Local Area Connection" static 208.67.222.222

All the steps below means you have access to the router via Telnet or physical access  and it already has a valid configuration (except the DNS)
On a Cisco Router is:
</span><span>Step 1:  <span>enable 
</span></span><span>Step 2: <span>configure <span>terminal 
</span></span></span><span>Step 3: <span>Do one of the following: <span><span>ip domain name name
                                                       </span><span><span>ip domain list </span><span>name
</span></span></span></span></span><span>Step 4 : Device(config)# ip name-server 172.16.1.111 172.16.1.2</span>
5 0
3 years ago
Where can I find information regarding different career choices in AZCIS?
Vadim26 [7]
I think Internet is the best way to search career choices. You can get a lot information.

4 0
3 years ago
What is a user data?
Rom4ik [11]

Answer:   Any data the user creates or owns.

Explanation:

the user being the one on the otherside of the computer, usually a human.

but examples of user data are intalled programs, uploads, word documents created by user (computer user)

7 0
3 years ago
Your foot brake must be able to stop your car within __________ when it is travelling at 20 mph.
ohaa [14]

Answer:

Your foot brake must be able to stop car within 5.18 m

Explanation:

d = s^{2}  / (250 * c_{f} )

d is breaking distance.

s is speed in km/h

c_{f} is coefficient of friction normally 0.8

250 is  constant.

Give the speed in mile first convert it to km/h

1 km = 1.60934 mile

speed in km= 20 * 1.60934

s =32.186 km/h

d=32.186^{2}  / (250 * 0.8)

d= 5.18m

7 0
2 years ago
Which of the following describes the purpose of a goal? Choose all that apply.
german
The first and last option
6 0
2 years ago
Read 2 more answers
Other questions:
  • Which two editions of Windows 7 support 64 bit CPUs? Choose two out of Professional, Business, Starter, or Home Premium.
    12·1 answer
  • Help plz
    5·1 answer
  • How do you increase the amount of data in a sampled Google Analytics report?
    8·1 answer
  • The WAN connections to your regional offices are unfortunately extremely slow for your users and they are complaining about file
    14·1 answer
  • 8.7 lesson practice question 1
    13·1 answer
  • Can you please help me
    9·1 answer
  • Output each floating-point value with two digits after the decimal point, which can be achieved by executing cout &lt;&lt; fixed
    7·1 answer
  • Use the drop-down menus to explain what happens when a manager assigns a task in Outlook.
    6·2 answers
  • What is the initial condition in this set of code?
    8·1 answer
  • A large global retail corporation has experienced a security breach, which includes personal data of employees and customers.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!