瀏覽代碼

added changes

Roy 6 年之前
父節點
當前提交
e16d4970cc
共有 2 個文件被更改,包括 24 次插入14 次删除
  1. 10
    0
      Operations.java
  2. 14
    14
      bonusFunctions.java

+ 10
- 0
Operations.java 查看文件

@@ -21,6 +21,7 @@ public class Operations
21 21
         scienticFunctions ScientificFunctions = new scienticFunctions();
22 22
         Memory memory = new Memory();
23 23
         DiplayMode displayMode = new DiplayMode();
24
+        bonusFunctions bonusFunctions = new bonusFunctions();
24 25
         // Calculator calc = new ....
25 26
         while (true) {
26 27
             System.out.print("Enter a command: ");
@@ -69,6 +70,15 @@ public class Operations
69 70
                 displayMode.switchDisplayMode(mode);
70 71
                 
71 72
             }
73
+            if (command.equalsIgnoreCase("log")){
74
+                Console.printResult(bonusFunctions.LogBaseTenOfAnumber(result));
75
+            }
76
+            if (command.equalsIgnoreCase("ln")){
77
+                Console.printResult(bonusFunctions.naturalLogLn(result));
78
+            }
79
+            if (command.equalsIgnoreCase("ex")){
80
+                Console.printResult(bonusFunctions.exponential(result));
81
+            }
72 82
             //firstNumber = result;
73 83
             // and on and on
74 84
         }

+ 14
- 14
bonusFunctions.java 查看文件

@@ -7,27 +7,27 @@
7 7
  */
8 8
 public class bonusFunctions
9 9
 {
10
-    // instance variables - replace the example below with your own
11
-    private int x;
12
-
13
-    /**
14
-     * Constructor for objects of class bonusFunctions
15
-     */
16
-    public bonusFunctions()
17
-    {
18
-        // initialise instance variables
19
-        x = 0;
20
-    }
21
-
22 10
     /**
23 11
      * An example of a method - replace this comment with your own
24 12
      *
25 13
      * @param  y  a sample parameter for a method
26 14
      * @return    the sum of x and y
27 15
      */
28
-    public int sampleMethod(int y)
16
+    public Double naturalLogLn(Double x)
17
+    {
18
+        // put your code here
19
+        return Math.log(x);
20
+    }
21
+    
22
+    public Double LogBaseTenOfAnumber(Double x)
23
+    {
24
+        // put your code here
25
+        return Math.log10(x);
26
+    }
27
+    
28
+    public Double exponential(Double x)
29 29
     {
30 30
         // put your code here
31
-        return x + y;
31
+        return Math.exp(x);
32 32
     }
33 33
 }