Giter Club home page Giter Club logo

makechangeproject's Introduction

#MakeChangeProject

Overview

This program simulates a cash register and provides change to customers in the appropriate currency.

Technologies Used

  • Java
  • Conditionals
  • Looping
  • Methods

How to Run

This is a console java program, so all that is needed is Java installed on your system, and a familiarity with console commands

  • Open the console
  • Run Javac MakeChange.java
    • this will compile your code into a runnable class file
  • Run Java MakeChange.class
  • Input the total amount of the item purchased
  • Input the tender given
  • Voila, you're done!

Lessons Learned

One of the biggest challenges faced with this program is getting past Java's own intricacies of how it handles operations with doubles. In order to properly do an operation with a double, we have to understand what computers do during floating point arithmetic, as opposed to whole numbers. Java has no issue with doing math concerning integers and presenting their solutions, because of the relative size in bits. Generally speaking, most day-to-day operations can be performed and return a value within the range of values an int can store. However, with decimal values, that range jumps significantly. In most programming languages, like Java, decimals are represented similarly to scientific notation. Instead of base 10 however, base 2 is used instead. Because their exponent cannot be a decimal, an integer must represent the value, which can cause rounding errors and issues for us when we need to have something as precise as giving exact change after a transaction. One way to avoid this altogether is to simply multiply the decimal portion by 100 and casting it back to an int. This would prevent any further rounding error from occurring.

One of the interesting things about the assignment is getting the grammar of the output right. Most of the code could be consolidated with the use of an array containing the values of the cash types and iterating through each with a loop. Since these solutions were not part of the assignment, taking time to make sure the output was correct for each block was of the utmost importance.

makechangeproject's People

Contributors

yufiles 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.