Zavon Malone 6 years ago
parent
commit
25ce0d3665
4 changed files with 38 additions and 25 deletions
  1. 6
    1
      LoopFun.java
  2. 4
    4
      MathUtilities.java
  3. 10
    1
      StringUtilities.java
  4. 18
    19
      package.bluej

+ 6
- 1
LoopFun.java View File

@@ -8,7 +8,12 @@ public class LoopFun
8 8
        * @return the factorial of the number
9 9
        */
10 10
       public int factorial(int number){
11
-          return -1;
11
+          int factor =1;
12
+          int max= number;
13
+          for(int i=1; i<=max; i++){
14
+            factor = factor*i;
15
+            }
16
+          return factor;
12 17
       }
13 18
 
14 19
       /**

+ 4
- 4
MathUtilities.java View File

@@ -6,7 +6,7 @@ public class MathUtilities{
6 6
    * @return the sum of the two numbers
7 7
    */
8 8
   public int add(int num1, int num2){
9
-      return -1;
9
+      return num1+num2;
10 10
   }
11 11
 
12 12
   /**
@@ -16,7 +16,7 @@ public class MathUtilities{
16 16
    * @return the sum of the two numbers
17 17
    */
18 18
   public double add(double num1, double num2){
19
-      return -1;
19
+      return num1+num2;
20 20
   }
21 21
 
22 22
   /**
@@ -25,7 +25,7 @@ public class MathUtilities{
25 25
    * @return the half of the number in double
26 26
    */
27 27
   public double half(int number) {
28
-      return -1;
28
+      return number*.5;
29 29
   }
30 30
 
31 31
   /**
@@ -44,7 +44,7 @@ public class MathUtilities{
44 44
    * @return the result of the number multiply by itself
45 45
    */
46 46
   public int square(int number) {
47
-      return -1;
47
+      return number*number;
48 48
   }
49 49
 
50 50
 }

+ 10
- 1
StringUtilities.java View File

@@ -1,6 +1,15 @@
1
+
2
+import java.util.Scanner;
1 3
 public class StringUtilities {
2 4
    public Character getMiddleCharacter(String word){
3
-       return null;
5
+       Scanner input=  new Scanner(System.in);
6
+       System.out.println("Enter word");
7
+       String letter = input.nextLine();
8
+       int mid= letter.length();
9
+       int z= mid/2;
10
+       char ch[]=letter.toCharArray();
11
+       System.out.println("Middle character is: ");
12
+       return ch[z];
4 13
    }
5 14
    
6 15
    public String removeCharacter(String value, char charToRemove){

+ 18
- 19
package.bluej View File

@@ -2,25 +2,25 @@
2 2
 dependency1.from=StringUtilitiesTest
3 3
 dependency1.to=StringUtilities
4 4
 dependency1.type=UsesDependency
5
-dependency2.from=BonusTest
6
-dependency2.to=Bonus
5
+dependency2.from=LoopFunTest
6
+dependency2.to=LoopFun
7 7
 dependency2.type=UsesDependency
8 8
 dependency3.from=MathUtilitiesTest
9 9
 dependency3.to=MathUtilities
10 10
 dependency3.type=UsesDependency
11 11
 editor.fx.0.height=722
12
-editor.fx.0.width=876
13
-editor.fx.0.x=158
14
-editor.fx.0.y=216
15
-objectbench.height=164
12
+editor.fx.0.width=709
13
+editor.fx.0.x=571
14
+editor.fx.0.y=23
15
+objectbench.height=150
16 16
 objectbench.width=669
17 17
 package.divider.horizontal=0.6
18
-package.divider.vertical=0.7628294036061026
19
-package.editor.height=543
18
+package.divider.vertical=0.7639097744360902
19
+package.editor.height=501
20 20
 package.editor.width=567
21
-package.editor.x=557
22
-package.editor.y=43
23
-package.frame.height=779
21
+package.editor.x=6
22
+package.editor.y=23
23
+package.frame.height=723
24 24
 package.frame.width=693
25 25
 package.numDependencies=3
26 26
 package.numTargets=6
@@ -40,20 +40,19 @@ target1.width=110
40 40
 target1.x=110
41 41
 target1.y=150
42 42
 target2.height=50
43
-target2.name=BonusTest
43
+target2.name=LoopFunTest
44 44
 target2.showInterface=false
45 45
 target2.type=UnitTestTargetJunit4
46
-target2.width=80
47
-target2.x=120
48
-target2.y=270
49
-target3.association=BonusTest
46
+target2.width=110
47
+target2.x=10
48
+target2.y=240
50 49
 target3.height=50
51
-target3.name=Bonus
50
+target3.name=LoopFun
52 51
 target3.showInterface=false
53 52
 target3.type=ClassTarget
54 53
 target3.width=80
55
-target3.x=90
56
-target3.y=300
54
+target3.x=200
55
+target3.y=210
57 56
 target4.association=MathUtilitiesTest
58 57
 target4.height=50
59 58
 target4.name=MathUtilities