Browse Source

new commit

David Thornley 6 years ago
parent
commit
e83f6c886e

BIN
Factorial.class View File


+ 5
- 0
Factorial.ctxt View File

1
+#BlueJ class context
2
+comment0.target=Factorial
3
+comment1.params=value
4
+comment1.target=java.math.BigInteger\ factorialOf(java.lang.Integer)
5
+numComments=2

+ 7
- 1
Factorial.java View File

6
 public class Factorial {
6
 public class Factorial {
7
 
7
 
8
     public BigInteger factorialOf(Integer value){
8
     public BigInteger factorialOf(Integer value){
9
-        return null;
9
+        long factorial = 1;
10
+        
11
+        for(long factor = 2; factor <= value; factor ++) {
12
+            factorial *= factor;
13
+        }
14
+        
15
+        return BigInteger.valueOf(factorial);
10
     }
16
     }
11
 
17
 
12
 }
18
 }

BIN
FactorialTest.class View File


+ 7
- 0
FactorialTest.ctxt View File

1
+#BlueJ class context
2
+comment0.target=FactorialTest
3
+comment1.params=
4
+comment1.target=void\ setUp()
5
+comment2.params=
6
+comment2.target=void\ factorialOfTest()
7
+numComments=3

BIN
IntegerPrinter.class View File


+ 11
- 0
IntegerPrinter.ctxt View File

1
+#BlueJ class context
2
+comment0.target=IntegerPrinter
3
+comment1.params=value
4
+comment1.target=java.lang.String\ printIntegerAsBinary(int)
5
+comment2.params=value
6
+comment2.target=java.lang.String\ printIntegerAsOctal(int)
7
+comment3.params=value
8
+comment3.target=java.lang.String\ printIntegerAsHexadecimal(int)
9
+comment4.params=args
10
+comment4.target=void\ main(java.lang.String[])
11
+numComments=5

+ 12
- 6
IntegerPrinter.java View File

1
- 
2
 
1
 
3
 
2
 
4
 public class IntegerPrinter {
3
 public class IntegerPrinter {
5
 
4
 
6
     public String printIntegerAsBinary(int value){
5
     public String printIntegerAsBinary(int value){
7
-        return null;
6
+
7
+        String b = Integer.toString(value,2);
8
+        System.out.println(b);
9
+        return b;
8
     }
10
     }
9
 
11
 
10
-    public String printIntegerAsOctal(int value){
11
-        return null;
12
+    public static String printIntegerAsOctal(int value){
13
+        String o = Integer.toString(value,8);
14
+        System.out.println(o);
15
+        return o;
12
     }
16
     }
13
 
17
 
14
-    public String printIntegerAsHexadecimal(int value){
15
-        return null;
18
+    public static String printIntegerAsHexadecimal(int value){
19
+        String h = Integer.toString(value,16);
20
+        System.out.println(h);
21
+        return h;
16
     }
22
     }
17
 
23
 
18
     public static void main(String[] args){
24
     public static void main(String[] args){

BIN
IntegerPrinterTest.class View File


+ 11
- 0
IntegerPrinterTest.ctxt View File

1
+#BlueJ class context
2
+comment0.target=IntegerPrinterTest
3
+comment1.params=
4
+comment1.target=void\ setUp()
5
+comment2.params=
6
+comment2.target=void\ printIntegerAsBinaryTest()
7
+comment3.params=
8
+comment3.target=void\ printIntegerAsHexadecimal()
9
+comment4.params=
10
+comment4.target=void\ printIntegerAsOctalTest()
11
+numComments=5

BIN
LargestInteger.class View File


+ 7
- 0
LargestInteger.ctxt View File

1
+#BlueJ class context
2
+comment0.target=LargestInteger
3
+comment1.params=integers
4
+comment1.target=java.lang.Integer\ findLargestNumberUsingConditional(java.lang.Integer[])
5
+comment2.params=integers
6
+comment2.target=java.lang.Integer\ findLargestNumberUsingMathMax(java.lang.Integer[])
7
+numComments=3

+ 7
- 2
LargestInteger.java View File

4
 public class LargestInteger {
4
 public class LargestInteger {
5
 
5
 
6
     public Integer findLargestNumberUsingConditional(Integer[] integers){
6
     public Integer findLargestNumberUsingConditional(Integer[] integers){
7
-        return null;
7
+        int one = integers[0] > integers[1] ? integers[0] : integers[1];
8
+        int two = one > integers[2] ? one : integers[2];
9
+        System.out.println(two);
10
+        return two;
8
     }
11
     }
9
 
12
 
10
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
13
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
11
-        return null;
14
+        int win = Math.max(integers[0], (Math.max(integers[1],integers[2])));
15
+        System.out.println(win);
16
+        return win;
12
     }
17
     }
13
 }
18
 }

BIN
LargestIntegerTest.class View File


+ 9
- 0
LargestIntegerTest.ctxt View File

1
+#BlueJ class context
2
+comment0.target=LargestIntegerTest
3
+comment1.params=
4
+comment1.target=void\ setUp()
5
+comment2.params=
6
+comment2.target=void\ findLargestNumberUsingConditionalTest()
7
+comment3.params=
8
+comment3.target=void\ findLargestNumberUsingMathMaxTest()
9
+numComments=4

BIN
NormalizeAngle.class View File


+ 9
- 0
NormalizeAngle.ctxt View File

1
+#BlueJ class context
2
+comment0.target=NormalizeAngle
3
+comment1.params=angle
4
+comment1.target=java.lang.Integer\ normalizeValueUsingModulo(java.lang.Integer)
5
+comment2.params=integer
6
+comment2.target=java.lang.Integer\ normalizeValueUsingFloorMod(java.lang.Integer)
7
+comment3.params=args
8
+comment3.target=void\ main(java.lang.String[])
9
+numComments=4

+ 6
- 2
NormalizeAngle.java View File

4
 public class NormalizeAngle {
4
 public class NormalizeAngle {
5
 
5
 
6
     public Integer normalizeValueUsingModulo(Integer angle){
6
     public Integer normalizeValueUsingModulo(Integer angle){
7
-        return 0;
7
+        int mod = angle % 360;
8
+        
9
+        return mod;
8
     }
10
     }
9
 
11
 
10
     public Integer normalizeValueUsingFloorMod(Integer integer){
12
     public Integer normalizeValueUsingFloorMod(Integer integer){
11
-        return 0;
13
+        int mod = Math.floorMod(integer, 360);
14
+        
15
+        return mod;
12
     }
16
     }
13
 
17
 
14
     public static void main(String[] args){
18
     public static void main(String[] args){

BIN
NormalizeAngleTest.class View File


+ 9
- 0
NormalizeAngleTest.ctxt View File

1
+#BlueJ class context
2
+comment0.target=NormalizeAngleTest
3
+comment1.params=
4
+comment1.target=void\ setUp()
5
+comment2.params=
6
+comment2.target=void\ normalizeValueUsingModuloTest()
7
+comment3.params=
8
+comment3.target=void\ normalizeValueUsingFloorModTest()
9
+numComments=4

BIN
ShortCalculator.class View File


+ 5
- 0
ShortCalculator.ctxt View File

1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+comment1.params=args
4
+comment1.target=void\ main(java.lang.String[])
5
+numComments=2

+ 51
- 0
ShortCalculator.java View File

1
  
1
  
2
 
2
 
3
+import java.util.Scanner;
3
 
4
 
4
 public class ShortCalculator {
5
 public class ShortCalculator {
6
+    
7
+    public static void main(String[] args){
8
+        //Create scanner to recieve user input
9
+        Scanner input = new Scanner(System.in);
10
+        
11
+        //Collects user input for numbers
12
+        System.out.println("Please Enter First Number: Between 1 - 65535");
13
+        int num1a = input.nextInt();
14
+        short num1 = (short)num1a;
15
+        
16
+        System.out.println("Please Enter Second Number: Between 1- 65535 ");
17
+        int num2a = input.nextInt();
18
+        short num2 = (short)num2a;
19
+        
20
+        //Create scanner to recieve operator
21
+        Scanner operator = new Scanner(System.in);
22
+        System.out.println("Please Choose An Operation (+, -, *, //, or %)");
23
+        
24
+        String op = operator.nextLine();
25
+        
26
+        //Create variable to hold result of math operation
27
+        short result = 0;
28
+        //Swtich statment showing math operations for cases based on operator 
29
+        
30
+        switch(op) {
31
+         case "+" : result = (short)(num1 + num2);
32
+                break;
33
+                case "-" : result = (short)(num1 - num2);
34
+                break;
35
+                case "*" : result = (short)(num1 * num2);
36
+                break;
37
+                case "//" : result = (short)(num1 / num2);
38
+                break;
39
+                case "%" : result = (short)(num1 % num2);
40
+                break;
41
+                default: System.out.print("Invalid Operator, Please Choose Another!");
42
+                break;     
43
+        }
44
+        
45
+        System.out.println(num1 + " " + op + " " + num2 + " = " + result);
46
+        
47
+        
48
+    }
49
+    
50
+    
51
+    
52
+    
5
 }
53
 }
54
+
55
+
56
+

BIN
ShortCalculatorTest.class View File


+ 3
- 0
ShortCalculatorTest.ctxt View File

1
+#BlueJ class context
2
+comment0.target=ShortCalculatorTest
3
+numComments=1

+ 7
- 7
package.bluej View File

15
 editor.fx.0.width=0
15
 editor.fx.0.width=0
16
 editor.fx.0.x=0
16
 editor.fx.0.x=0
17
 editor.fx.0.y=0
17
 editor.fx.0.y=0
18
-objectbench.height=101
19
-objectbench.width=1070
20
-package.divider.horizontal=0.6
21
-package.divider.vertical=0.837593984962406
22
-package.editor.height=550
18
+objectbench.height=99
19
+objectbench.width=637
20
+package.divider.horizontal=0.5996275605214153
21
+package.divider.vertical=0.8381679389312977
22
+package.editor.height=542
23
 package.editor.width=968
23
 package.editor.width=968
24
 package.editor.x=59
24
 package.editor.x=59
25
-package.editor.y=82
26
-package.frame.height=723
25
+package.editor.y=23
26
+package.frame.height=713
27
 package.frame.width=1094
27
 package.frame.width=1094
28
 package.numDependencies=4
28
 package.numDependencies=4
29
 package.numTargets=10
29
 package.numTargets=10