Roy vor 6 Jahren
Ursprung
Commit
f0486943bd
2 geänderte Dateien mit 29 neuen und 3 gelöschten Zeilen
  1. 3
    0
      Console.java
  2. 26
    3
      Operations.java

+ 3
- 0
Console.java Datei anzeigen

@@ -14,6 +14,9 @@ public class Console {
14 14
     public static void println(String output, Object... args) {
15 15
         print(output + "\n", args);
16 16
     }
17
+    public static void printResult(Double result) {
18
+        System.out.println(result);
19
+    }
17 20
 
18 21
     public static String getStringInput(String prompt) {
19 22
         Scanner scanner = new Scanner(System.in);

+ 26
- 3
Operations.java Datei anzeigen

@@ -55,16 +55,39 @@ public class Operations
55 55
                 result  = ScientificFunctions.sine(firstNumber);
56 56
                 //firstNumber = result;
57 57
                 //result = firstNumber;
58
+                Console.printResult(result);
58 59
             }
59 60
             if (command.equalsIgnoreCase("cos"))  {
60 61
                 // read first number
61 62
                 firstNumber = input.nextDouble();
62
-                // call the square method on calc and display
63
+                // call the cosine method on calc and display
63 64
                 result  = ScientificFunctions.cos(firstNumber);
65
+                Console.printResult(result);
64 66
             }
65
-            //if (command.equalsIgnoreCase("hex"))  {
67
+            if (command.equalsIgnoreCase("tan"))  {
66 68
             // call the square method on calc and display
67
-            //}
69
+                firstNumber = input.nextDouble();
70
+                result = ScientificFunctions.tangent(firstNumber);
71
+                Console.printResult(result);
72
+            }
73
+            if (command.equalsIgnoreCase("cos-1"))  {
74
+            // call the square method on calc and display
75
+                firstNumber = input.nextDouble();
76
+                result = ScientificFunctions.inverseCosine(firstNumber);
77
+                Console.printResult(result);
78
+            }
79
+            if (command.equalsIgnoreCase("sin-1"))  {
80
+            // call the square method on calc and display
81
+                firstNumber = input.nextDouble();
82
+                result = ScientificFunctions.inverseSine(firstNumber);
83
+                Console.printResult(result);
84
+            }
85
+            if (command.equalsIgnoreCase("tan-1"))  {
86
+            // call the square method on calc and display
87
+                firstNumber = input.nextDouble();
88
+                result = ScientificFunctions.inverseTangent(firstNumber);
89
+                Console.printResult(result);
90
+            }
68 91
             firstNumber = result;
69 92
             // and on and on
70 93
         }