瀏覽代碼

alfredo something

Alfredo Castillo 6 年之前
父節點
當前提交
b20e07e47d
共有 1 個檔案被更改,包括 72 行新增18 行删除
  1. 72
    18
      Calculator.java

+ 72
- 18
Calculator.java 查看文件

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