Pārlūkot izejas kodu

Committing BasicComputations

chitraBegerhotta 6 gadus atpakaļ
vecāks
revīzija
1bd1f7e67d

Binārs
Factorial.class Parādīt failu


+ 5
- 0
Factorial.ctxt Parādīt failu

@@ -0,0 +1,5 @@
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

+ 5
- 1
Factorial.java Parādīt failu

@@ -6,7 +6,11 @@ import java.math.BigInteger;
6 6
 public class Factorial {
7 7
 
8 8
     public BigInteger factorialOf(Integer value){
9
-        return null;
9
+        BigInteger k = new BigInteger("1");
10
+        for(int i=1; i<=value; i++){
11
+            k = k.multiply(BigInteger.valueOf(i));
12
+        }
13
+        return k;
10 14
     }
11 15
 
12 16
 }

Binārs
FactorialTest.class Parādīt failu


+ 7
- 0
FactorialTest.ctxt Parādīt failu

@@ -0,0 +1,7 @@
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ārs
IntegerPrinter.class Parādīt failu


+ 11
- 0
IntegerPrinter.ctxt Parādīt failu

@@ -0,0 +1,11 @@
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
- 3
IntegerPrinter.java Parādīt failu

@@ -4,18 +4,27 @@
4 4
 public class IntegerPrinter {
5 5
 
6 6
     public String printIntegerAsBinary(int value){
7
-        return null;
7
+        
8
+        String strBinary = Integer.toBinaryString(value);
9
+        return strBinary;
10
+        
8 11
     }
9 12
 
10 13
     public String printIntegerAsOctal(int value){
11
-        return null;
14
+        
15
+        String strOctal = Integer.toOctalString(value);
16
+        return strOctal;
17
+        
12 18
     }
13 19
 
14 20
     public String printIntegerAsHexadecimal(int value){
15
-        return null;
21
+        
22
+        String strHexa = Integer.toHexString(value);
23
+        return strHexa;
16 24
     }
17 25
 
18 26
     public static void main(String[] args){
27
+        IntegerPrinter intPrint = new IntegerPrinter();
19 28
 
20 29
     }
21 30
 }

Binārs
IntegerPrinterTest.class Parādīt failu


+ 11
- 0
IntegerPrinterTest.ctxt Parādīt failu

@@ -0,0 +1,11 @@
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ārs
LargestInteger.class Parādīt failu


+ 7
- 0
LargestInteger.ctxt Parādīt failu

@@ -0,0 +1,7 @@
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

+ 10
- 2
LargestInteger.java Parādīt failu

@@ -4,10 +4,18 @@
4 4
 public class LargestInteger {
5 5
 
6 6
     public Integer findLargestNumberUsingConditional(Integer[] integers){
7
-        return null;
7
+        int largestNum = 0;
8
+        for(int i=0; i<integers.length; i++){
9
+            if(largestNum < integers[i]){
10
+                largestNum = integers[i];
11
+            }
12
+        }
13
+        return largestNum;
8 14
     }
9 15
 
10 16
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
11
-        return null;
17
+        int largestNum = Math.max(integers[0], integers[1]);
18
+        int result = Math.max(integers[2], largestNum);
19
+        return result;
12 20
     }
13 21
 }

Binārs
LargestIntegerTest.class Parādīt failu


+ 9
- 0
LargestIntegerTest.ctxt Parādīt failu

@@ -0,0 +1,9 @@
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ārs
NormalizeAngle.class Parādīt failu


+ 9
- 0
NormalizeAngle.ctxt Parādīt failu

@@ -0,0 +1,9 @@
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

+ 9
- 2
NormalizeAngle.java Parādīt failu

@@ -4,14 +4,21 @@
4 4
 public class NormalizeAngle {
5 5
 
6 6
     public Integer normalizeValueUsingModulo(Integer angle){
7
-        return 0;
7
+        int newAngle = angle;
8
+        while(newAngle < 0) newAngle += 360;
9
+        while(newAngle > 359) newAngle -= 360;
10
+        return newAngle;
8 11
     }
9 12
 
10 13
     public Integer normalizeValueUsingFloorMod(Integer integer){
11
-        return 0;
14
+        int normalize1 = Math.floorMod(integer, 360);
15
+        return normalize1;
12 16
     }
13 17
 
14 18
     public static void main(String[] args){
19
+        
20
+        NormalizeAngle norangle = new NormalizeAngle();
21
+        
15 22
 
16 23
     }
17 24
 }

Binārs
NormalizeAngleTest.class Parādīt failu


+ 9
- 0
NormalizeAngleTest.ctxt Parādīt failu

@@ -0,0 +1,9 @@
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ārs
ShortCalculator.class Parādīt failu


+ 5
- 0
ShortCalculator.ctxt Parādīt failu

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

+ 28
- 2
ShortCalculator.java Parādīt failu

@@ -1,5 +1,31 @@
1
- 
1
+ import java.util.Scanner;
2 2
 
3 3
 
4 4
 public class ShortCalculator {
5
-}
5
+   
6
+    
7
+    public static void main(String[] args){
8
+         
9
+        Scanner scanner = new Scanner(System.in);
10
+        
11
+        System.out.println("Please enter a number:");
12
+        short num = scanner.nextShort();
13
+        
14
+        System.out.println("Please enter another number:");
15
+        short num2 = scanner.nextShort();
16
+        
17
+        short a = (short)(num + num2);
18
+        short s = (short)(num - num2);
19
+        short m = (short)(num * num2);
20
+        short d = (short)(num / num2);
21
+        short r = (short)(num % num2);
22
+        
23
+        System.out.println("The sum of x and y: " + a);
24
+        System.out.println("The difference of x and y: " + s);
25
+        System.out.println("The multiplication of x and y: " + m);
26
+        System.out.println("The division of x and y: " + d);
27
+        System.out.println("The remainder of x and y: " + r);
28
+    }
29
+        
30
+    }
31
+    

Binārs
ShortCalculatorTest.class Parādīt failu


+ 3
- 0
ShortCalculatorTest.ctxt Parādīt failu

@@ -0,0 +1,3 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculatorTest
3
+numComments=1

+ 6
- 1
ShortCalculatorTest.java Parādīt failu

@@ -1,5 +1,10 @@
1
- 
1
+import org.junit.Assert;
2
+import org.junit.Before;
3
+import org.junit.Test;
2 4
 
3 5
 
4 6
 public class ShortCalculatorTest {
7
+    
8
+    
5 9
 }
10
+

+ 8
- 8
package.bluej Parādīt failu

@@ -11,18 +11,18 @@ dependency3.type=UsesDependency
11 11
 dependency4.from=IntegerPrinterTest
12 12
 dependency4.to=IntegerPrinter
13 13
 dependency4.type=UsesDependency
14
-editor.fx.0.height=0
15
-editor.fx.0.width=0
16
-editor.fx.0.x=0
17
-editor.fx.0.y=0
14
+editor.fx.0.height=722
15
+editor.fx.0.width=800
16
+editor.fx.0.x=376
17
+editor.fx.0.y=28
18 18
 objectbench.height=101
19
-objectbench.width=1070
20
-package.divider.horizontal=0.6
19
+objectbench.width=637
20
+package.divider.horizontal=0.5996275605214153
21 21
 package.divider.vertical=0.837593984962406
22 22
 package.editor.height=550
23 23
 package.editor.width=968
24
-package.editor.x=59
25
-package.editor.y=82
24
+package.editor.x=25
25
+package.editor.y=27
26 26
 package.frame.height=723
27 27
 package.frame.width=1094
28 28
 package.numDependencies=4