Преглед на файлове

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

Jamez-s преди 6 години
родител
ревизия
526442d21b
променени са 2 файла, в които са добавени 24 реда и са изтрити 14 реда
  1. 10
    0
      Operations.java
  2. 14
    14
      bonusFunctions.java

+ 10
- 0
Operations.java Целия файл

21
         scienticFunctions ScientificFunctions = new scienticFunctions();
21
         scienticFunctions ScientificFunctions = new scienticFunctions();
22
         Memory memory = new Memory();
22
         Memory memory = new Memory();
23
         DiplayMode displayMode = new DiplayMode();
23
         DiplayMode displayMode = new DiplayMode();
24
+        bonusFunctions bonusFunctions = new bonusFunctions();
24
         // Calculator calc = new ....
25
         // Calculator calc = new ....
25
         while (true) {
26
         while (true) {
26
             System.out.print("Enter a command: ");
27
             System.out.print("Enter a command: ");
69
                 displayMode.switchDisplayMode(mode);
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
             //firstNumber = result;
82
             //firstNumber = result;
73
             // and on and on
83
             // and on and on
74
         }
84
         }

+ 14
- 14
bonusFunctions.java Целия файл

7
  */
7
  */
8
 public class bonusFunctions
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
      * An example of a method - replace this comment with your own
11
      * An example of a method - replace this comment with your own
24
      *
12
      *
25
      * @param  y  a sample parameter for a method
13
      * @param  y  a sample parameter for a method
26
      * @return    the sum of x and y
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
         // put your code here
30
         // put your code here
31
-        return x + y;
31
+        return Math.exp(x);
32
     }
32
     }
33
 }
33
 }