Skip to content

An arithmetic expression calculator for e.g. a * ( b + c ) / d. you can pass on dependent variable and get the output.

Notifications You must be signed in to change notification settings

yachShekhar/expression-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This is arithmetic expression calculater. For e.g you have an expression like (a + b) * 100. Based upon value of a & b this will give the answer. For more details you can refer to Test.java file.

Note: you can try out any complex formula.

Sample code:

    Map<String, BigDecimal> data = new HashMap<>();
    data.put("a", BigDecimal.valueOf(100));
    data.put("b", BigDecimal.valueOf(2));
    data.put("c", BigDecimal.valueOf(12));
    data.put("d", BigDecimal.valueOf(14));
    data.put("e", BigDecimal.valueOf(6));
    System.out.println("a * ( b + c ) / d  ==>"+ExpressionParser.init("a * ( b + c ) / d").evaluate(data).getData());


    System.out.println("a * ( b + c )   ==>"+ExpressionParser.init("a * ( b + c)").evaluate(data).getData());


    System.out.println("a +  b  * e  ==>"+ExpressionParser.init("a +  b  * e").evaluate(data).getData());


    System.out.println("(c - b) * 100.1  ==>"+ExpressionParser.init("(c -  b) * 100.1").evaluate(data).getData());

Output:

    a * ( b + c ) / d  ==>100
    a * ( b + c )   ==>1400
    a +  b  * e  ==>112
    (c - b) * 100.1  ==>1001.0

About

An arithmetic expression calculator for e.g. a * ( b + c ) / d. you can pass on dependent variable and get the output.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy