In Python with only variables, arithmetic operators, and conditionals (No while, No for, No List) can you:   Design and implement program that writes out what bills and coins would be dispensed if this machine existed for the amount of money that was entered. The money dispenser should be grammatically correct. One of the most challenging parts of the float is a result of the imprecision of floating point numbers. Avoid this issue by converting the value that is entered in the keyboard into an integer. For example, if 123.45 (the amount in dollars) is entered into the keyboard, you should convert it to 12345 (the amount in cents). This is common practice when dealing with dollar amounts when it does make sense to have parts of a cent. The behavior of round() for floats can be surprising: for example, round(2.675, 2) gives 2.67 instead of the expected 2.68. This is not a bug: it’s a result of the fact that most decimal fractions can’t be represented exactly as a float. To avoid this issue, you should use integers instead of floats. Ex: Enter amount: 123.45 6 twenties 3 ones 1 quarter 2 dimes

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In Python with only variables, arithmetic operators, and conditionals (No while, No for, No List) can you:  

Design and implement program that writes out what bills and coins would be dispensed if this machine existed for the amount of money that was entered. The money dispenser should be grammatically correct.

One of the most challenging parts of the float is a result of the imprecision of floating point numbers. Avoid this issue by converting the value that is entered in the keyboard into an integer. For example, if 123.45 (the amount in dollars) is entered into the keyboard, you should convert it to 12345 (the amount in cents). This is common practice when dealing with dollar amounts when it does make sense to have parts of a cent.

The behavior of round() for floats can be surprising: for example, round(2.675, 2) gives 2.67 instead of the expected 2.68. This is not a bug: it’s a result of the fact that most decimal fractions can’t be represented exactly as a float. To avoid this issue, you should use integers instead of floats.

Ex:

Enter amount: 123.45

6 twenties

3 ones

1 quarter

2 dimes

Expert Solution
program


amt=float(input("Enter the amount:"))
amt=amt*100
print(int(amt//2000),"twenties")#to find twenties
amt=amt%2000#to calculate remaining amount after removing twenties
print(int(amt//1000),"tens")#to find tens
amt=amt%1000#to find remaining amount after removing twenties, tens
print(int(amt//500),"fives")# to find fives
amt=amt%500#to find remaining amount after removing twenties, tens, fives
print(int(amt//100),"Ones")#to find ones
amt=amt%100#to find remaining amount after removing tens,twenties,tens,fives
print(int(amt//25),"quaters")#to find quaters
amt=amt%25#to find remaining amount after removing tens,twenties,tens,fives,quaters
print(int(amt//10),"dimes")#to find dimes
amt=amt%10#to find remaining amount after removing tens,twenties,tens,fives,quaters,dimes
print(int(amt//5),"nickels")#to find nickels
amt=amt%5#to find remaining amount after removing tens,twenties,tens,fives,quaters,dimes,nickels
print(int(amt),"pennies")# to print remaining ones which are pennies

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY