Giter VIP home page Giter VIP logo

cash-register's Introduction

cash-register

Create a cash register that should be able to accept only $20, $10, $5, $2 and $1 bills. Given the charge and amount of money received return the change in each denomination that should be given from the cash register. Sometimes when the vendors couldn’t make exact change they would tell us they couldn’t make exact change. It’s safe to assume that all output will be printed to the command line, below are some examples of how it would be used.

start program, waiting for command.

> java Main ...

ready

show current state in total and each denomination: $Total #$20 #$10 #$5 #$2 #$1. for example $68 1 2 3 4 5 means: Total=$68 $20x1 $10x2 $5x3 $2x4 $1x5.

> show

$68 1 2 3 4 5

put bills in each denomination: #$20 #$10 #$5 #$2 #$1 (show current state).

> put 1 2 3 0 5

$128 2 4 6 4 10

take bills in each denomination: #$20 #$10 #$5 #$2 #$1 (show current state).

> take 1 4 3 0 5

$48 1 0 3 4 5

given amount.

show change in each denomination: #$20 #$10 #$5 #$2 #$1 (and remove money from cash register).

> change 8

0 0 1 1 1

> show

$40 1 0 2 3 4

show error if there is insufficient fund or no change can be made.

> change 97

sorry

exit program.

> quit

bye

How to build and run it

You can just type this command at the root project folder to build it.

gradle build

Then you can navigate to the "build/libs" folder and execute the following JAR command line.

java -jar cash-register-X.X.X.jar

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.