瀏覽代碼

very minor edits

Margaret Pierse 6 年之前
父節點
當前提交
a7129daa5d
共有 3 個檔案被更改,包括 15 行新增7 行删除
  1. 10
    4
      Calculator.java
  2. 3
    1
      MathMethods.java
  3. 2
    2
      Memory.java

+ 10
- 4
Calculator.java 查看文件

@@ -34,6 +34,7 @@ public class Calculator{
34 34
             } else {
35 35
                 switch (toDo) {
36 36
                     //System.out.println("toDO is: " + toDo);
37
+                    
37 38
                     case "add":
38 39
                     case "subtract":
39 40
                     case "multiply":
@@ -51,12 +52,17 @@ public class Calculator{
51 52
                     case "tangent" :
52 53
                     case "inverse tangent" :
53 54
                     case "inverse" :
54
-                    case "M+" :
55
+                    
55 56
                     System.out.println(toDo + " -- Enter first number:");
56 57
                     num1 = input1.nextDouble();
57 58
                     //System.out.println("num1 is: " + num1);
58 59
                 }
59 60
                 switch (toDo){
61
+                    // case "previous":
62
+                    // num1 = lastAns;
63
+                    // System.out.println(toDo + " -- Enter second number:");
64
+                    // num2 = input1.nextDouble();
65
+                    //break;
60 66
                     case "add":
61 67
                     case "subtract":
62 68
                     case "multiply":
@@ -69,6 +75,8 @@ public class Calculator{
69 75
                 }
70 76
 
71 77
                 switch (toDo) {        
78
+                    
79
+                    
72 80
                     case "add":
73 81
                     result = calc.add(num1, num2);
74 82
                     lastAns = result;
@@ -206,9 +214,7 @@ public class Calculator{
206 214
                     break;
207 215
 
208 216
                     case "M+" :
209
-                    System.out.println("Enter number:");
210
-                    num1 = input1.nextDouble();
211
-                    result = Memory.memUpdate(num1);
217
+                    result = Memory.memUpdate(lastAns);
212 218
                     Memory.printAns(String.valueOf(result));
213 219
                     break;
214 220
 

+ 3
- 1
MathMethods.java 查看文件

@@ -71,12 +71,14 @@ public class MathMethods
71 71
 
72 72
     public static String fortuneCookie() {
73 73
         Random rand = new Random();
74
+         
74 75
         String[] wiseWords = new String[] {"You're a hard worker and you will do great on all the labs!", 
75 76
                 "Look how much java you learned this week! That's awesome!", 
76 77
                 "Keep up the good work!" ,
77 78
                 "You're cushing it!", "You're a coding rockstar!", 
78 79
                 "Keep coding!"};  
79 80
         int arrIndex = rand.nextInt(6);
81
+        System.out.println(arrIndex);
80 82
         return wiseWords[arrIndex];
81 83
     }
82 84
 
@@ -135,7 +137,7 @@ public class MathMethods
135 137
     }
136 138
 
137 139
     public static void printAns(String printAnswer){
138
-        System.out.println("ANSWER: " + printAnswer + "\n \n");
140
+        System.out.println( String.valueOf(printAnswer));
139 141
     }
140 142
 
141 143
     public static double inverse(double n1) {

+ 2
- 2
Memory.java 查看文件

@@ -20,9 +20,9 @@ public class Memory
20 20
         return mem;    
21 21
     }
22 22
     
23
-    public static double memUpdate(double n1) 
23
+    public static double memUpdate(double lastAns) 
24 24
     {
25
-        return n1;
25
+        return mem = lastAns;
26 26
     }
27 27
     
28 28
     public static double memClear()