Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Python: Making Change Ask the user how much change to give the customer: How much change should the customer get? If the change is less

Python: Making Change

  • Ask the user how much change to give the customer: "How much change should the customer get?"
  • If the change is less than zero
    • Print an error: "Change must be a positive integer"
    • Return to the top of this algorithm
  • Determine the number of quarters, nickels, dimes, and pennies to return (hint: use division and modulus....)
  • Print: "Return the following change:"
  • If there are quarters to return
    • Print: "X quarters"
  • If there are dimes to return
    • Print: "X dimes"
  • If there are nickels to return
    • Print: "X nickels"
  • If there are pennies to return
    • Print: "X pennies"
  • Ask the user: "Would you like to make more change? (y/Y/n/N)"
  • If they respond with y or Y
    • Print "Let's make some more change!"
    • Repeat this entire algorithm
  • Otherwise, if they respond with n or N
    • Print "Ok, I'll move along to something else..."
    • Move on to Part 3
  • Otherwise
    • Print "I did not recognize that response"
    • Repeat the prompt asking them if they want to make more change

Assumptions

  • You can assume that the value for the change will be an integer
  • You do not have to correct for singular/plural quarters/nickels/dimes/pennies

Requirements

To solve this problem (and receive full credit on the design), you must use the following python features:

  • while loop
  • "Truthy/Falsey" values
  • continue

Exact Input:

-56 87 y 56 Y 35 blah n Exact Output:
How much change should the customer get? Change must be a positive integer How much change should the customer get? Return the following change: 3 quarters 1 dimes 2 pennies Would you like to make more change? (y/Y/n/N) Let's make some more change! How much change should the customer get? Return the following change: 2 quarters 1 nickels 1 pennies Would you like to make more change? (y/Y/n/N) Let's make some more change! How much change should the customer get? Return the following change: 1 quarters 1 dimes Would you like to make more change? (y/Y/n/N) I did not recognize that response Would you like to make more change? (y/Y/n/N) Ok, I'll move along to something else...

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions