From 02dddde371b72ef4da4e86d5290c0aa40cf09667 Mon Sep 17 00:00:00 2001 From: Nimit Arora Date: Thu, 5 Oct 2017 22:24:00 +0530 Subject: [PATCH] Postfix Evaluation --- Misc/PostfixEvaluation.java | 70 +++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Misc/PostfixEvaluation.java 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