Code Monkey home page Code Monkey logo

calculator's Introduction

Overview

Simple command line calculator. Supports the following operations: add, sub, mult, div, and let. The operations can be nested as can be seen in the examples below. The let operation allows a value to be assigned to a variable and the variable can then be used in the calculation. All operations can be nested. Some examples below show some use cases.

Examples Answer
add(2, 5) 7.0
sub(1, 9) -8.0
mult(3, 14) 42.0
div(47, 2) 23.5
add(2, mult(3, 4)) 14.0
let(a, 5, add(a, a)) 10.0
let(a, 5, let(b, mult(a, 10), add(b, a))) 55
let(a, let(b, 10, add(b, b)), let(b, 20, add(a, b))) 40
let(a, 5, let(b, mult(a, let(c, 4, add(c,a))), add(c, b))) 49

Requirements

  • Maven
  • Java
  • Internet connection (downloading dependencies)

Building

Step-by-step instructions on how to build the code from source

  1. Clone the repository:
    git clone https://github.com/cwagnello/calculator
  1. Run maven
    mvn clean package 

Running

Given an executable jar file. The Calculator can be run as follows:

    java -DLOG_LEVEL=INFO -Dlogback.configurationFile=<path/to/config/file>/logback.xml -jar Calculator-0.2.0.jar

The logging is done via logback. The log level can be set by passing in the system property LOG_LEVEL. Also the configuration file for logback needs to be specified as one is not built into the application. A sample config is included in the project at logback.xml

Continuous Integration

https://app.circleci.com/pipelines/github/cwagnello/calculator

#TODOs

  • Add more error checking on inputs
  • Add CircleCI config to store jar artifact

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.