Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in python 1 Goals . Practice with if statements and Boolean expressions. - Practice manipulating numeric values that represent fixed- precision fractional numbers. Dealing with
in python
1 Goals . Practice with if statements and Boolean expressions. - Practice manipulating numeric values that represent fixed- precision fractional numbers. Dealing with currency amounts can seem tricky, since something like $1.23 seems like a real number, but floating-point arithmetic is prone to precision problems, as demonstrated in Python's REPL: .2 + 3 == .1 + 2 + .3 1+ True >>>.1 + False .2 + .3 .1 + (.2 + .3) In the case of U.S. currency, things become much easier if you convert everything to cents, such that $1.23 is really just 123 cents. Make sure to use the built-in round() function to ensure that you aren't suffering from any floating-point weirdness like the above! >>> int float 8.95') * 100) 894 >>> int round float 8.95'). 895 Assignment You shall write a Python program that reads (without a prompt) a real number from standard input. Assuming that value represents an amount in U.S. currency, the program shall then proceed to print out how that amount could be represented using the fewest bills and coins, assuming that only the following bills and coins exist: Steve Brule - Wh.. $100 bills $50 bills $20 bills $10 bills $5 bills $1 bills Quarters ($0.25) Dimes ($0.10) - Nickels ($0.05) Pennies ($0.01) Specifications Describe the bills and coins needed to represent the amount using the fewest number of bills and coins, in descending order of value, with one line of output per bill/coin amount. 1. Format your output according to the table and sample sessions below, using the following pattern: (number of bills/coins] (plural/ 2. If no amount of a certain bill or coin is needed, do not print any information about it. For example, if the amount is less than a dollar, your output should not mention bills of any kind. Bill/Coin $100 bill $50 bill Plural Description hundreds N/A twenties Singular Description hundred fifty twenty $20 bill N/A ten $10 bill $5 bill N/A five $1 bill ones one quarters quarter Quarter ($0.25) dimes dime Dime ($0.10) N/A nickel Nickel ($0.05) pennies penny Penny ($0.01) Sample Executable and Example I/O There is a sample executable on the server named cs12p_currency. Feel free to run it and see an example of what your 10 is expected to look like. Four possible sessions follow, using here strings for input. $ cs12p_currency Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started