-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexpression.java
More file actions
29 lines (26 loc) · 802 Bytes
/
Copy pathexpression.java
File metadata and controls
29 lines (26 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import Classes.*;
import java.util.*;
public class expression
{
public static void main(String[] args)
{
Scanner reader = new Scanner(System.in);
s_expression exp;
System.out.print("\nEnter expression : ");
String temp = reader.nextLine();
exp = new s_expression(temp);
s_variable_table table = exp.get_variables_table();
List<String> variable_names = table.get_variable_names();
while(true)
{
System.out.println("\nEnter variable values");
for(int i=0;i<variable_names.size();i++)
{
System.out.print("\nEnter value of "+variable_names.get(i)+" : ");
temp = reader.next();
table.add_variable(variable_names.get(i),temp);
}
System.out.println("\nValue = "+Float.toString(exp.evaluate(table)));
}
}
}