浏览代码

conflicts fixed

Allison Ziegler 6 年前
父节点
当前提交
3f16a86b88
共有 1 个文件被更改,包括 62 次插入33 次删除
  1. 62
    33
      Calculator.java

+ 62
- 33
Calculator.java 查看文件

@@ -1,7 +1,5 @@
1 1
 
2
-
3 2
 public class Calculator
4
-
5 3
 {
6 4
     // instance variables - replace the example below with your own
7 5
     private double displayValue;
@@ -15,106 +13,137 @@ public class Calculator
15 13
         displayValue = 0;
16 14
         memoryValue = 0;
17 15
     }
18
-    
19
-    
16
+
20 17
     //Memory set
21 18
     public double memSet(){
22 19
         memoryValue = displayValue;
23 20
         return memoryValue;
24 21
     }
22
+
25 23
     public double memClear(){
26 24
         memoryValue = 0;
27 25
         return memoryValue;
28 26
     }
27
+
29 28
     public double mrc(){
30 29
         displayValue = memoryValue;
31 30
         return displayValue;
32 31
     }
33
-    
32
+
34 33
     //Clear and retrieve display value
35 34
     public double clear(){
36 35
         displayValue = 0;
37 36
         err = false;
38 37
         return displayValue;
39 38
     }
39
+
40 40
     public double getDisplayValue(){
41 41
         return displayValue;
42 42
     }
43
-    
44
-    public boolean getErrorState(){
45
-        return err;
46
-    }
47
-    
43
+
48 44
     //basic functions
49 45
     public double add(double value1, double value2){
50 46
         displayValue = value1 + value2;
51 47
         return displayValue;
52 48
     }
49
+
53 50
     public double subtract(double value1, double value2){
54 51
         displayValue  = value1 - value2;
55 52
         return displayValue;
56 53
     }
54
+
57 55
     public double multiply(double value1, double value2){
58 56
         displayValue = value1 * value2;
59 57
         return displayValue;
60 58
     }
59
+
61 60
     public double divide(double dividend, double divisor){
62 61
         displayValue = dividend / divisor;
63 62
         return displayValue;
64 63
     }
64
+
65 65
     public double pow(double base, double exponent){
66 66
         displayValue = Math.pow(base, exponent);
67 67
         return displayValue;
68 68
     }
69
+
69 70
     public double square(double base){
70 71
         return pow(base, 2);
71 72
     }
73
+
72 74
     public double squareRoot(double value){
73 75
         displayValue = Math.sqrt(value);
74 76
         return displayValue;
75 77
     }
78
+
76 79
     public double inverse(double value){
77 80
         displayValue = 1 / value;
78 81
         return displayValue;
79 82
     }
83
+
80 84
     public double changeSign(double value){
81 85
         return multiply(value, -1);
82 86
     }
83
-    
87
+
84 88
     //scientific functions
85
-    public double sin(double angle){
86
-        return 0;
89
+    public double sin(double value){
90
+        displayValue = Math.sin(value);
91
+        return displayValue;
87 92
     }
88
-    public double cos(double angle) {
89
-        return 0;
93
+
94
+    public double cos(double value) {
95
+        displayValue = Math.cos(value);
96
+        return displayValue;
90 97
     }
91
-    public double tan(double angle) {
92
-        return 0;
98
+
99
+    public double tan(double value) {
100
+        displayValue = Math.tan(value);
101
+        return displayValue;
102
+    }
103
+
104
+    public double log(double value) {
105
+        displayValue = Math.log(value);
106
+        return displayValue;
93 107
     }
94
-    public double inverseTan(double angle) {
95
-        return 0;
108
+
109
+    public double inverseSin(double value) {
110
+        displayValue = Math.log(value);
111
+        return displayValue;
96 112
     }
97
-    public double inverseSin(double angle) {
98
-        return 0;
113
+
114
+    public double inverseCos(double value) {
115
+        displayValue = Math.acos(value);
116
+        return displayValue;
99 117
     }
100
-    public double inverseCos(double angle) {
101
-        return 0;
118
+
119
+    public double inverseTan(double value) {
120
+        displayValue = Math.atan(value);
121
+        return displayValue;
102 122
     }
103
-    public double log(double val){
104
-        return 0;
123
+
124
+    public double inverseLog(double value){
125
+        displayValue = Math.pow(value, 10);
126
+        return displayValue;
105 127
     }
106
-    public double  inverseLog(double val){
107
-        return 0;
128
+
129
+    public double naturalLog(double value) {
130
+        displayValue = Math.log1p(value);
131
+        return displayValue;
108 132
     }
109
-    public double inverseLn(double val){
110
-        return 0;
133
+
134
+    public double inverseLn(double value) {
135
+        displayValue = Math.pow(Math.E, value);
136
+        return displayValue;
111 137
     }
112
-    public double displayPi(){
113
-        return 0;
138
+
139
+    public double displayPi() {
140
+        displayValue = Math.PI;
141
+        return displayValue;
114 142
     }
143
+
115 144
     public double displayE(){
116
-        return 0;
145
+    displayValue = Math.E;
146
+    return Math.E;
117 147
     }
118 148
 
119
-   
120 149
 }