Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*3.8 (Financial application: monetary units) Rewrite Listing 3.4, ComputeChange.py, to fix the possible loss of accuracy when converting a float value to an int value.

*3.8 (Financial application: monetary units) Rewrite Listing 3.4, ComputeChange.py, to fix the possible loss of accuracy when converting a float value to an int value. Enter the input as an integer whose last two digits represent the cents. For example, the input 1156 represents 11 dollars and 56 cents.

Python Help! PLEASE EXPLAIN IT TO ME HOW YOU SOLVE THIS.

image text in transcribed

1 Introduction to progan area atnentagon in LISTING 3.4 ComputeChange.py 1 # Receive the amount 2 amount eval(inputC"Enter an anount, for example, 11.56: ")) enter input # Convert the amount to cents S remainingAmountint(anount 100) 7 # Find the number of one dollars 8 numberDfoneDollars remainingAnount 100 dollars 9 remaining/mount = remainingAmount % 100 10 11 # Find the number of quarters in the remaining amount 12 numberDfquarters -remainingAmount 25 13 remainingAmount=remainingAmount %25 14 15 # Find the number of dimes in the remaining amount 16 numberDfDimes remainingAmount10O 17 remainingAmount = remainingAmount % 10 18 19 # Find the number of nickels in the remaining amount 20 numberofNickels remainingAmount S 21 remainingAmount=remainingAmount %5 quarters dimes nickels 23 # Find the number of pennies in the remaining amount 24 numberOfPennies remainingAmount 25 26 Display the results 27 print( Your amount", anount, "consists ofn" 28 29 30 31 32 peunies outpu "t", nunberofonelars, "dollars ", "t", numberOfQuarters, "quarters ". "\t", numberOfDimes, "dinesn" "t", numberOfNickels, "nickels'n". "t", numberOfPennies, "pennies") Enter an amount, for example, 11.56: 11.56 Your anount 11.56 consists of 11 do1lars 2 quarters 0 dimes 1 nickels 1 pennies

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

| Who are people who model the values that I want to live?

Answered: 1 week ago

Question

| In what ways am 1 striving to make their lives better?

Answered: 1 week ago

Question

| Whom can I trust to help me make sure that I am living my values?

Answered: 1 week ago