diff --git a/Misc/PostfixEvaluation.java b/Misc/PostfixEvaluation.java new file mode 100644 index 000000000000..ab70a4f2a54e --- /dev/null +++ b/Misc/PostfixEvaluation.java @@ -0,0 +1,70 @@ +import java.util.Scanner; +import java.util.Stack; + +/* +This Program will evaluate the value of given Postfix Expression + */ + +public class PostfixEvaluation { + public static void main(String[] args) { + // Inserting Postfix Expression + System.out.println("Enter Postfix Expression"); + Scanner s=new Scanner(System.in); + String exp=s.next(); + int answer=PostEval(exp); + System.out.println("The Value of expression is : "+answer); + } + + //Function to Evaluate Postfix Expression + + private static int PostEval(String exp) { + Stack helperStack=new Stack<>(); + int i=0; + while(i