Seth 6 years ago
parent
commit
dbe64c303a
4 changed files with 99 additions and 27 deletions
  1. 20
    2
      Calculator.java
  2. 27
    0
      Console.java
  3. 20
    0
      Memory.java
  4. 32
    25
      package.bluej

+ 20
- 2
Calculator.java View File

@@ -27,6 +27,24 @@ public class Calculator
27 27
     double result = x/y;
28 28
     return result;
29 29
     }
30
-
31
-  
30
+    
31
+    public static double square(double x) {
32
+    double result = Math.pow(x, 2);
33
+    return result;
34
+    }
35
+    
36
+    public static double inverse(double x) {
37
+    double result = x;
38
+    return result;
39
+    }
40
+    
41
+    public static double tangent(double x) {
42
+    double result = Math.tan(x);
43
+    return result;
44
+    }
45
+    
46
+    public static double itan(double x) {
47
+    double result = Math.atan(x);
48
+    return result;
49
+    }
32 50
 }

+ 27
- 0
Console.java View File

@@ -61,6 +61,33 @@ public class Console {
61 61
                 ultimateAnswer = Double.toString(answer);
62 62
                 return ultimateAnswer;
63 63
                 
64
+            case "square" :
65
+                System.out.println("Enter your number:");
66
+                userInput = scanner.nextDouble();
67
+                answer = Calculator.square(userInput);
68
+                ultimateAnswer = Double.toString(answer);
69
+                return ultimateAnswer;
70
+                
71
+            case "inverse" :
72
+                System.out.println("Enter your number:");
73
+                userInput = scanner.nextDouble();
74
+                answer = Calculator.inverse(userInput);
75
+                ultimateAnswer = String.format("1/%.0f", answer);
76
+                return ultimateAnswer;   
77
+                
78
+            case "tangent" :
79
+                System.out.println("Enter your number:");
80
+                userInput = scanner.nextDouble();
81
+                answer = Calculator.tangent(userInput);
82
+                ultimateAnswer = Double.toString(answer);
83
+                return ultimateAnswer;
84
+                
85
+            case "inverse tangent" :
86
+                System.out.println("Enter your number:");
87
+                userInput = scanner.nextDouble();
88
+                answer = Calculator.itan(userInput);
89
+                ultimateAnswer = Double.toString(answer);
90
+                return ultimateAnswer;
64 91
             case "quit" :
65 92
                     return "quit";
66 93
            

+ 20
- 0
Memory.java View File

@@ -0,0 +1,20 @@
1
+
2
+/**
3
+ * Write a description of class Memory here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class Memory
9
+{
10
+    // instance variables - replace the example below with your ow
11
+
12
+
13
+
14
+    public void memorySet(double x)
15
+    {
16
+        mem = x;
17
+    }
18
+    
19
+    public void memoryRecall(double x)
20
+}

+ 32
- 25
package.bluej View File

@@ -1,26 +1,26 @@
1 1
 #BlueJ package file
2
-dependency1.from=MainApplication
3
-dependency1.to=Console
2
+dependency1.from=Console
3
+dependency1.to=Calculator
4 4
 dependency1.type=UsesDependency
5
-dependency2.from=Console
6
-dependency2.to=Calculator
5
+dependency2.from=MainApplication
6
+dependency2.to=Console
7 7
 dependency2.type=UsesDependency
8
-editor.fx.0.height=1020
9
-editor.fx.0.width=1247
10
-editor.fx.0.x=2093
11
-editor.fx.0.y=165
8
+editor.fx.0.height=765
9
+editor.fx.0.width=863
10
+editor.fx.0.x=601
11
+editor.fx.0.y=-945
12 12
 objectbench.height=80
13
-objectbench.width=352
13
+objectbench.width=595
14 14
 package.divider.horizontal=0.5993322203672788
15 15
 package.divider.vertical=0.8465608465608465
16
-package.editor.height=473
16
+package.editor.height=457
17 17
 package.editor.width=493
18
-package.editor.x=1446
19
-package.editor.y=445
18
+package.editor.x=102
19
+package.editor.y=-1057
20 20
 package.frame.height=625
21 21
 package.frame.width=619
22 22
 package.numDependencies=2
23
-package.numTargets=3
23
+package.numTargets=4
24 24
 package.showExtends=true
25 25
 package.showUses=true
26 26
 project.charset=UTF-8
@@ -30,23 +30,30 @@ readme.width=47
30 30
 readme.x=10
31 31
 readme.y=10
32 32
 target1.height=50
33
-target1.name=Calculator
33
+target1.name=Memory
34 34
 target1.showInterface=false
35 35
 target1.type=ClassTarget
36
-target1.width=90
37
-target1.x=200
38
-target1.y=310
36
+target1.width=80
37
+target1.x=400
38
+target1.y=120
39 39
 target2.height=50
40
-target2.name=Console
40
+target2.name=Calculator
41 41
 target2.showInterface=false
42 42
 target2.type=ClassTarget
43
-target2.width=80
44
-target2.x=80
45
-target2.y=200
43
+target2.width=90
44
+target2.x=200
45
+target2.y=310
46 46
 target3.height=50
47
-target3.name=MainApplication
47
+target3.name=Console
48 48
 target3.showInterface=false
49 49
 target3.type=ClassTarget
50
-target3.width=120
51
-target3.x=70
52
-target3.y=70
50
+target3.width=80
51
+target3.x=80
52
+target3.y=200
53
+target4.height=50
54
+target4.name=MainApplication
55
+target4.showInterface=false
56
+target4.type=ClassTarget
57
+target4.width=120
58
+target4.x=70
59
+target4.y=70