Seth 6 年前
父节点
当前提交
4cb8748048
共有 5 个文件被更改,包括 129 次插入12 次删除
  1. 15
    9
      Calculator.java
  2. 14
    2
      MathMethods.java
  3. 1
    1
      Memory.java
  4. 18
    0
      README-CheckItOut.txt.rtf
  5. 81
    0
      package.bluej

+ 15
- 9
Calculator.java 查看文件

@@ -1,12 +1,7 @@
1
+
1 2
 import java.util.*;
2 3
 
3 4
 
4
-/**
5
- * Write a description of class Calculator here.
6
- *
7
- * @author (your name)
8
- * @version (a version number or a date)
9
- */
10 5
 public class Calculator{
11 6
     public static double lastAns = 0;
12 7
 
@@ -17,13 +12,17 @@ public class Calculator{
17 12
         double num2 = 0;            //The user's second input
18 13
         double result = 0;          //The user's answer
19 14
         boolean off = false;        //The user typed quit, becomes true
15
+        double memory;
16
+
17
+ 
20 18
         boolean error = false;
21 19
         MathMethods calc = new MathMethods();
22 20
 
23 21
         while (off == false){
24 22
             Scanner input1 = new Scanner(System.in);
25 23
             System.out.println("What do you want to do?");
26
-            toDo = input1.next();
24
+
25
+            toDo = input1.nextLine();
27 26
 
28 27
             if (toDo.equalsIgnoreCase("quit")){
29 28
                 off = true;
@@ -223,13 +222,20 @@ public class Calculator{
223 222
                     Memory.printAns(String.valueOf(result));
224 223
                     break;
225 224
                     
225
+                    case "roundTo":
226
+                    memory = result;
227
+                    calc.roundTo(memory, (int)num1);
228
+                    break;
229
+                    
226 230
                     case "clear":
227 231
                     lastAns = 0;
228 232
                     break;
233
+                                     
234
+                    }
229 235
                 }
230 236
             }
231 237
         }
232
-    }
233 238
 
234
-}
239
+    }
235 240
 
241
+    

+ 14
- 2
MathMethods.java 查看文件

@@ -1,5 +1,7 @@
1 1
 import java.util.*;
2
+
2 3
 import java.lang.*;
4
+
3 5
 /**
4 6
  * Write a description of class Calculator here.
5 7
  *
@@ -9,8 +11,10 @@ import java.lang.*;
9 11
 public class MathMethods
10 12
 
11 13
 {
14
+
12 15
     private static int displayModeCounter=4;
13 16
 
17
+
14 18
     public static Double add(double n1, double n2){
15 19
         return (n1 + n2);
16 20
     }
@@ -69,14 +73,16 @@ public class MathMethods
69 73
 
70 74
     }
71 75
 
76
+
72 77
     public static String fortuneCookie() {
73 78
         Random rand = new Random();
79
+         
74 80
         String[] wiseWords = new String[] {"You're a hard worker and you will do great on all the labs!", 
75 81
                 "Look how much java you learned this week! That's awesome!", 
76 82
                 "Keep up the good work!" ,
77 83
                 "You're cushing it!", "You're a coding rockstar!", 
78 84
                 "Keep coding!"};  
79
-        int arrIndex = rand.nextInt(6);
85
+        int arrIndex = rand.nextInt(wiseWords.length);
80 86
         return wiseWords[arrIndex];
81 87
     }
82 88
 
@@ -136,7 +142,7 @@ public class MathMethods
136 142
     }
137 143
 
138 144
     public static void printAns(String printAnswer){
139
-        System.out.println("ANSWER: " + printAnswer + "\n \n");
145
+        System.out.println( "ANSWER: " + printAnswer + " \n \n");
140 146
     }
141 147
 
142 148
     public static double inverse(double n1) {
@@ -156,5 +162,11 @@ public class MathMethods
156 162
         return (display.lastAns);
157 163
     }
158 164
 
165
+    public static void roundTo(Double memory, int numPlaces){
166
+
167
+        System.out.printf("ANSWER: %." + (numPlaces)+ "f\n", memory);
168
+
169
+    }
159 170
 }
160 171
 
172
+

+ 1
- 1
Memory.java 查看文件

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

+ 18
- 0
README-CheckItOut.txt.rtf 查看文件

@@ -0,0 +1,18 @@
1
+{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf600
2
+{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
3
+{\colortbl;\red255\green255\blue255;}
4
+{\*\expandedcolortbl;;}
5
+\margl1440\margr1440\vieww10800\viewh8400\viewkind0
6
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
7
+
8
+\f0\fs24 \cf0 Team: Calc Crew\
9
+	\
10
+	Seth Abrams\
11
+	Nathan Hall\
12
+	Maggie Pierce\
13
+	\
14
+\
15
+Additional Features:\
16
+- Fortune Cookie\
17
+- Random Number\
18
+- Rounding}

+ 81
- 0
package.bluej 查看文件

@@ -1,6 +1,13 @@
1 1
 #BlueJ package file
2
+<<<<<<< HEAD
2 3
 dependency1.from=MemoryTest
3 4
 dependency1.to=Memory
5
+=======
6
+<<<<<<< HEAD
7
+<<<<<<< HEAD
8
+dependency1.from=Calculator
9
+dependency1.to=MathMethods
10
+>>>>>>> b807549eab014b3118ccfbb5b6e7d95cbb256af2
4 11
 dependency1.type=UsesDependency
5 12
 dependency2.from=MathMethodsTest
6 13
 dependency2.to=MathMethods
@@ -21,6 +28,7 @@ editor.fx.0.y=-1001
21 28
 objectbench.height=93
22 29
 objectbench.width=721
23 30
 package.divider.horizontal=0.5993322203672788
31
+<<<<<<< HEAD
24 32
 package.divider.vertical=0.8493975903614458
25 33
 package.editor.height=557
26 34
 package.editor.width=619
@@ -29,6 +37,34 @@ package.editor.y=-750
29 37
 package.frame.height=722
30 38
 package.frame.width=745
31 39
 package.numDependencies=5
40
+=======
41
+package.divider.vertical=0.8465608465608465
42
+package.editor.height=473
43
+package.editor.width=493
44
+package.editor.x=-188
45
+package.editor.y=-610
46
+package.frame.height=625
47
+=======
48
+dependency1.from=Calculator
49
+dependency1.to=MathMethods
50
+dependency1.type=UsesDependency
51
+editor.fx.0.height=722
52
+editor.fx.0.width=800
53
+editor.fx.0.x=0
54
+editor.fx.0.y=132
55
+objectbench.height=205
56
+objectbench.width=595
57
+package.divider.horizontal=0.6
58
+package.divider.vertical=0.6849925705794948
59
+package.editor.height=454
60
+package.editor.width=493
61
+package.editor.x=35
62
+package.editor.y=23
63
+package.frame.height=731
64
+>>>>>>> a0c06052a8de50df57cd0a41d73ffc3f9ce302c2
65
+package.frame.width=619
66
+package.numDependencies=4
67
+>>>>>>> b807549eab014b3118ccfbb5b6e7d95cbb256af2
32 68
 package.numTargets=5
33 69
 package.showExtends=true
34 70
 package.showUses=true
@@ -39,8 +75,37 @@ readme.width=47
39 75
 readme.x=10
40 76
 readme.y=10
41 77
 target1.height=50
78
+<<<<<<< HEAD
42 79
 target1.name=MemoryTest
80
+=======
81
+target1.name=Calculator
82
+>>>>>>> a0c06052a8de50df57cd0a41d73ffc3f9ce302c2
43 83
 target1.showInterface=false
84
+<<<<<<< HEAD
85
+=======
86
+<<<<<<< HEAD
87
+target1.type=ClassTarget
88
+<<<<<<< HEAD
89
+target1.width=140
90
+target1.x=80
91
+target1.y=200
92
+target2.height=50
93
+target2.name=MathMethodsTest
94
+target2.showInterface=false
95
+target2.type=UnitTestTargetJunit4
96
+target2.width=110
97
+target2.x=270
98
+target2.y=310
99
+target3.association=MathMethodsTest
100
+target3.height=50
101
+target3.name=MathMethods
102
+target3.showInterface=false
103
+target3.type=ClassTarget
104
+target3.width=110
105
+target3.x=240
106
+target3.y=340
107
+=======
108
+>>>>>>> b807549eab014b3118ccfbb5b6e7d95cbb256af2
44 109
 target1.type=UnitTestTargetJunit4
45 110
 target1.width=80
46 111
 target1.x=400
@@ -75,3 +140,19 @@ target5.type=ClassTarget
75 140
 target5.width=110
76 141
 target5.x=60
77 142
 target5.y=280
143
+<<<<<<< HEAD
144
+=======
145
+>>>>>>> 2a9a289e4239250cd6e2f776f8cc64f1130c5a52
146
+=======
147
+target1.width=120
148
+target1.x=70
149
+target1.y=70
150
+target2.height=50
151
+target2.name=MathMethods
152
+target2.showInterface=false
153
+target2.type=ClassTarget
154
+target2.width=110
155
+target2.x=80
156
+target2.y=200
157
+>>>>>>> a0c06052a8de50df57cd0a41d73ffc3f9ce302c2
158
+>>>>>>> b807549eab014b3118ccfbb5b6e7d95cbb256af2