ソースを参照

Merge branch 'master' of nedredmond/ZCW-MacroLabs-OOP-ScientificCalculator into master

William Brown 6 年 前
コミット
84745a670c
共有2 個のファイルを変更した34 個の追加26 個の削除を含む
  1. 15
    6
      advOp.java
  2. 19
    20
      opSwitch.java

+ 15
- 6
advOp.java ファイルの表示

@@ -9,11 +9,20 @@ import java.util.*;
9 9
 public class advOp
10 10
 {
11 11
     
12
-    // public static double add(double x, double y){
13
-        // //CALULATES THE SUM OF TWO NUMBERS
14
-        // Console.currentNumber = x + y;
15
-        // //System.out.println(currentNumber);
16
-        // return Console.currentNumber;
17
-    // }
12
+    public static double log(double x){
13
+        //CALULATES THE LOG OF NUMBER
14
+        Console.currentNumber = Math.log(x);
15
+        //System.out.println(currentNumber);
16
+        return Console.currentNumber;
17
+    }
18
+    
19
+    public static double nthRoot(double x, double n){
20
+        //CALULATES THE LOG OF NUMBER
21
+        Console.currentNumber = Math.pow(Math.E, Math.log(x)/n);
22
+        //System.out.println(currentNumber);
23
+        return Console.currentNumber;
24
+    }
25
+    
26
+    
18 27
 
19 28
 }

+ 19
- 20
opSwitch.java ファイルの表示

@@ -31,16 +31,16 @@ public class opSwitch
31 31
                 +"M+"+"\n"
32 32
                 +"MC"+"\n"
33 33
                 +"MRC"+"\n"
34
-                +"x rooted WIP"+"\n"
34
+                +"nth root"+"\n"
35 35
                 +"log WIP"+"\n"
36 36
                 +"ln WIP"+"\n"
37 37
                 +"log (CHANGE OF BASE ) WIP"+"\n"
38
-                +"sin WIP"+"\n"
39
-                +"cos WIP"+"\n"
40
-                +"tan WIP"+"\n"
41
-                +"inverse of sin WIP"+"\n"
42
-                +"inver of cos WIP"+"\n"
43
-                +"inverse of tan WIP"+"\n");
38
+                +"sin"+"\n"
39
+                +"cos"+"\n"
40
+                +"tan"+"\n"
41
+                +"asin"+"\n"
42
+                +"acos"+"\n"
43
+                +"atan"+"\n");
44 44
             break;
45 45
             case "+": 
46 46
                 //x = Console.getStringInput("Please enter first number.");
@@ -94,31 +94,30 @@ public class opSwitch
94 94
             case "MRC":
95 95
                 Memory.recallMemory();
96 96
                 break;
97
-            case "x rooted":
97
+            case "nth root":
98
+                y = Console.getStringInput("Please enter the value of n.");
99
+                advOp.nthRoot(op.currentNumber, Console.getNumber(y));
98 100
                 break;
99 101
             case "log":
100
-                break;
101
-            case "ln":
102
-                break;
103
-            case "log (change of base)":
102
+                advOp.log(op.currentNumber);
104 103
                 break;
105 104
             case "sin":
106 105
                 Trigonometry.sin(op.currentNumber);
107 106
                 break;
108 107
             case "cos":
109
-            Trigonometry.cos(op.currentNumber);
108
+                Trigonometry.cos(op.currentNumber);
110 109
                 break;
111 110
             case "tan":
112
-            Trigonometry.tan(op.currentNumber);
111
+                Trigonometry.tan(op.currentNumber);
113 112
                 break;
114
-            case "inverse of sin":
115
-            Trigonometry.sinInverse(op.currentNumber);
113
+            case "asin":
114
+                Trigonometry.sinInverse(op.currentNumber);
116 115
                 break;
117
-            case "inverse of cos":
118
-            Trigonometry.cosInverse(op.currentNumber);
116
+            case "acos":
117
+                Trigonometry.cosInverse(op.currentNumber);
119 118
                 break;
120
-            case "inverse of tan":
121
-            Trigonometry.tanInverse(op.currentNumber);
119
+            case "atan":
120
+                Trigonometry.tanInverse(op.currentNumber);
122 121
                 break;
123 122
         }
124 123
     }