-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpObj.java
More file actions
37 lines (37 loc) · 1 KB
/
pObj.java
File metadata and controls
37 lines (37 loc) · 1 KB
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
30
31
32
33
34
35
36
37
import java.lang.Math;
public class pObj{
public double num=0;
String oper="";
String paren="";
String sciop="";
public int mode=0; //0:numbers 1: operators(+,-) 2: parenthesis 3: scientific operator(sin cos) 4: x values
public pObj(int i,String str){
mode=i;
if(mode==0){
if(str.equals("e")){num=Math.E;}
else if(str.equals("p")){num=Math.PI;}
else{
num=Double.parseDouble(str);}
}
if(mode==1){
oper=str;
}
if(mode==2){
paren=str;
}
if(mode==3){
if(str.equals("c")){sciop="cos";}
if(str.equals("s")){sciop="sin";}
if(str.equals("t")){sciop="tan";}
if(str.equals("l")){sciop="log";}
}
}
public String toString(){
if(mode==0){
return(Double.toString(num));}
if(mode==1){return(oper);}
if(mode==2){return(paren);}
if(mode==3){return(sciop);}
else{return("x");}
}
}