Code Monkey home page Code Monkey logo

exact-change's Introduction

Exact Change

As a team write a computer program for an electronic vending machine to give you the exact change for an item's cost. Write a function called exact_change that takes in two arguments: item_cost, amount_paid, and currency as an optional argument with a default value of USD. The function should return a string describing the exact change which follows the following convention:

print(exact_change(62.13, 100))
> "The exact change for an item that costs $62.13 with an amount paid of $100 is 1 $20 bill, 1 $10 bill, 1 $5 bill, 2 $1 bills, 3 quarters, 1 dime, and 2 pennies."

print(exact_change(31.51, 50))
> "The exact change for an item that costs $31.51 with an amount paid of $50 is 1 $10 bill, 1 $5 bill, 3 $1 bills, 1 quarter, 2 dimes, and 4 pennies."

Team Instructions:

  • Inside of your exact_change function create helper functions that will account for different currencies of amount_paid but will keep item_cost as USD.
    • Japanese Yen
    • Euros
    • Mexican Pesos
    • Russian Ruble

Some helpful notes:

  • Your algorithm should compute the optimal change. Obviously, you can give the change in pennies, but we're looking for the most optimal (least amount of) change possible.
  • You should only consider common monetary denominations (i.e. ignore any denomination larger than $100-bill, ignore $2-bills, half-dollars, etc...)
  • You should fully understand the data types of your input and output
  • You need to account for proper plural denominations (i.e., quarters, dimes, pennies, bills) and proper punctuation (i.e., commas, using "and", and the period at the end of a sentence).
  • You need to account for for edge cases and special cases! We haven't specified what to return for special cases, so decide what you think is most sensible.
  • You should not worry too much about floating point rounding errors (but see if you can handle it if you know how to).

exact-change's People

Contributors

chaser164 avatar dave4283 avatar mikemac15 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.