Professional Documents
Culture Documents
On
<TITLE>
SUBMITTED BY:
<190030159> <B.VINAY>
<190030150> <B.POOJITHA>
<190031222> <B.UPENDRA>
Sri N.Sreeram
ASSOCIATE PROFESSOR
KL UNIVERSITY
Green fields, Vaddeswaram – 522 502
Guntur Dt., AP, India.
DEPARTMENT OF BASIC ENGINEERING SCIENCES
CERTIFICATE
I express the sincere gratitude to our director Dr. A Jagadeesh for his
administration towards our academic growth.
190030201 B.SasiVardhan
190031222 B.Upendra
ABSTRACT
This program reads standard expressions typed in by
the user.
The program constructs an expression tree to
represent the
expression. It then prints the value of the
tree. It also uses
the tree to print out a list of commands that
could be used
on a stack machine to evaluate the expression.
The expressions can use positive real numbers and
the binary operators +, -, *, and /. The unary
minus operation
is supported. The expressions are defined by the
BNF rules:
7 Conclusion <14>
INTRODUCTION
Advantages:-
Disadvantages:-
SYSTEM REQUIREMENTS
SOFTWARE REQUIREMENTS:
The major software requirements of the project are as follows:
Language : JAVA
Operating system: Windows 10 or later.
HARDWARE REQUIREMENTS:
The hardware requirements that map towards the software are as follows:
import java.util.Scanner;
public class ExpressionTree {
class TreeNode
{
char data;
TreeNode left, right;
switch (operator)
{
case '+' : result = left + right; break;
case '-' : result = left - right; break;
case '*' : result = left * right; break;
case '/' : result = left / right; break;
default : result = left + right; break;
}
return result;
}
}
System.out.print("\nPrefix : ");
et.prefix();
System.out.print("\n\nInfix : ");
et.infix();
System.out.print("\n\nPostfix : ");
et.postfix();
System.out.println("\n\nEvaluated Result : "+ et.evaluate());
}
}
OUTPUTS
Screen Shots:
CONCLUSION