Browse Source

Committing BasicComputations

chitraBegerhotta 6 years ago
parent
commit
1bd1f7e67d

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

+ 5
- 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
+        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
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
- 3
IntegerPrinter.java View File

4
 public class IntegerPrinter {
4
 public class IntegerPrinter {
5
 
5
 
6
     public String printIntegerAsBinary(int value){
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
     public String printIntegerAsOctal(int value){
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
     public String printIntegerAsHexadecimal(int value){
20
     public String printIntegerAsHexadecimal(int value){
15
-        return null;
21
+        
22
+        String strHexa = Integer.toHexString(value);
23
+        return strHexa;
16
     }
24
     }
17
 
25
 
18
     public static void main(String[] args){
26
     public static void main(String[] args){
27
+        IntegerPrinter intPrint = new IntegerPrinter();
19
 
28
 
20
     }
29
     }
21
 }
30
 }

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

+ 10
- 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 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
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
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
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

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

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

+ 28
- 2
ShortCalculator.java View File

1
- 
1
+ import java.util.Scanner;
2
 
2
 
3
 
3
 
4
 public class ShortCalculator {
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
ShortCalculatorTest.class View File


+ 3
- 0
ShortCalculatorTest.ctxt View File

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

+ 6
- 1
ShortCalculatorTest.java View File

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

+ 8
- 8
package.bluej View File

11
 dependency4.from=IntegerPrinterTest
11
 dependency4.from=IntegerPrinterTest
12
 dependency4.to=IntegerPrinter
12
 dependency4.to=IntegerPrinter
13
 dependency4.type=UsesDependency
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
 objectbench.height=101
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
 package.divider.vertical=0.837593984962406
21
 package.divider.vertical=0.837593984962406
22
 package.editor.height=550
22
 package.editor.height=550
23
 package.editor.width=968
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
 package.frame.height=723
26
 package.frame.height=723
27
 package.frame.width=1094
27
 package.frame.width=1094
28
 package.numDependencies=4
28
 package.numDependencies=4