Pārlūkot izejas kodu

very minor edits

Margaret Pierse 6 gadus atpakaļ
vecāks
revīzija
a7129daa5d
3 mainītis faili ar 15 papildinājumiem un 7 dzēšanām
  1. 10
    4
      Calculator.java
  2. 3
    1
      MathMethods.java
  3. 2
    2
      Memory.java

+ 10
- 4
Calculator.java Parādīt failu

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

+ 3
- 1
MathMethods.java Parādīt failu

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

+ 2
- 2
Memory.java Parādīt failu

20
         return mem;    
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
     public static double memClear()
28
     public static double memClear()