Skip to content

With insane speed, solve mathematical expressions at runtime in a string using "Evaluater" class in Java.

License

Notifications You must be signed in to change notification settings

saksham-joshi/Eval-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔢 Eval-Java 🔢

Python has a function called eval() used to solve mathematical expressions in a string but Java has nothing like this, so i developed this algorithm which can do so.

You can use this package to create a calculator which can solve complex mathematical expressions.

Average Time Complexity: **O(n)**

Average Space Complexity: **O(k + m)**

📝 Sample code

import evaluater.Evaluater;
import evaluater.EvaluaterExceptions;

public class sample {

    public static void main(String[] args)
    {
        try
        {
            
            Evaluater eval = new Evaluater("1280.33/(12*-10.11)");
            System.out.println(eval.evaluate());
        }
        catch(EvaluaterExceptions.InvalidMathExpression excep)
        {
            System.out.println(excep);
        }
    }
    
}

NOTE: evaluate() methods throw InvalidMathExpression exception if the given expression is invalid.

➗ Supported operators ➕

Operators Name Precedence
+ Addition 1
- Subtraction 1
x,*,X Multiplication 2
/,÷ Division 2
% Modulus 2
^ Power 3
! Not 4

🔗 Developer Links

portfolio linkedin Github X(Twitter) Static Badge


About

With insane speed, solve mathematical expressions at runtime in a string using "Evaluater" class in Java.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages