Skip to content

Commit 79d29c0

Browse files
committed
Comment revisions
1 parent 862ac23 commit 79d29c0

10 files changed

+42
-12
lines changed

Conversions/DecimalToBinary.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* This class converts a Decimal number to a Binary number
77
*
8-
* @author Unknown
8+
*
99
*/
1010
class DecimalToBinary {
1111

Conversions/DecimalToHexaDecimal.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package Conversions;
22

3+
//hex = [0 - 9] -> [A - F]
34
class DecimalToHexaDecimal {
45
private static final int sizeOfIntInHalfBytes = 8;
56
private static final int numberOfBitsInAHalfByte = 4;

Conversions/DecimalToOctal.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
/**
66
* This class converts Decimal numbers to Octal Numbers
77
*
8-
* @author Unknown
8+
*
99
*/
1010
public class DecimalToOctal {
1111
/**
1212
* Main Method
1313
*
1414
* @param args Command line Arguments
1515
*/
16+
17+
//enter in a decimal value to get Octal output
1618
public static void main(String[] args) {
1719
Scanner sc = new Scanner(System.in);
1820
int n, k, d, s = 0, c = 0;

Conversions/HexaDecimalToBinary.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package Conversions;
22

3+
//Hex [0-9],[A-F] -> Binary [0,1]
4+
35
public class HexaDecimalToBinary {
46

57
private final int LONG_BITS = 8;
@@ -9,7 +11,7 @@ public void convert(String numHex) {
911
int conHex = Integer.parseInt(numHex, 16);
1012
// Hex a Binary:
1113
String binary = Integer.toBinaryString(conHex);
12-
// Presentation:
14+
// Output:
1315
System.out.println(numHex + " = " + completeDigits(binary));
1416
}
1517

Conversions/IntegerToRoman.java

+20
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
package Conversions;
22

3+
/**
4+
* Converting Integers into Roman Numerals
5+
*
6+
*('I', 1);
7+
*('IV',4);
8+
*('V', 5);
9+
*('IV',9);
10+
*('X', 10);
11+
*('XL',40;
12+
*('L', 50);
13+
*('XC',90);
14+
*('C', 100);
15+
*('D', 500);
16+
*('M', 1000);
17+
*
18+
*/
19+
20+
321
public class IntegerToRoman {
422
private static int[] allArabianRomanNumbers = new int[]{1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
523
private static String[] allRomanNumbers = new String[]{"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
624

25+
//Value must be > 0
26+
727
public static String integerToRoman(int num) {
828
if (num <= 0) {
929
return "";

Conversions/RomanToInteger.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class RomanToInteger {
1313
put('D', 500);
1414
put('M', 1000);
1515
}};
16+
//Roman Number = Roman Numerals
1617

1718
/**
1819
* This function convert Roman number into Integer

Maths/AbsoluteMax.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static void main(String[] args) {
1515
}
1616

1717
/**
18-
* get the value, it's absolute value is max
18+
* get the value, return the absolute max value
1919
*
2020
* @param numbers contains elements
2121
* @return the absolute max value

Maths/AbsoluteMin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static void main(String[] args) {
1515
}
1616

1717
/**
18-
* get the value, it's absolute value is min
18+
* get the value, returns the absolute min value min
1919
*
2020
* @param numbers contains elements
2121
* @return the absolute min value

Maths/Factorial.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
package Maths;
22

3+
//change around 'n' for different factorial results
34
public class Factorial {
45
public static void main(String[] args) {
56
int n = 5;
67
System.out.println(n + "! = " + factorial(n));
78
}
89

10+
//Factorial = n! = n1 * (n-1) * (n-2)*...1
11+
912
/**
10-
* Calculate factorial
13+
* Calculate factorial N
1114
*
1215
* @param n the number
1316
* @return the factorial of {@code n}
1417
*/
1518
public static long factorial(int n) {
1619
if (n < 0) {
17-
throw new ArithmeticException("n < 0");
20+
throw new ArithmeticException("n < 0"); //Dont work with less than 0
1821
}
1922
long fac = 1;
2023
for (int i = 1; i <= n; ++i) {
2124
fac *= i;
2225
}
23-
return fac;
26+
return fac; //Return factorial
2427
}
2528
}

Maths/Pow.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package maths;
22

3+
//POWER (exponentials) Examples (a^b)
34
public class Pow {
45
public static void main(String[] args) {
5-
assert pow(2, 0) == Math.pow(2, 0);
6-
assert pow(0, 2) == Math.pow(0, 2);
7-
assert pow(2, 10) == Math.pow(2, 10);
8-
assert pow(10, 2) == Math.pow(10, 2);
6+
assert pow(2, 0) == Math.pow(2, 0); // == 1
7+
assert pow(0, 2) == Math.pow(0, 2); // == 0
8+
assert pow(2, 10) == Math.pow(2, 10); // == 1024
9+
assert pow(10, 2) == Math.pow(10, 2); // == 100
910
}
1011

1112
/**

0 commit comments

Comments
 (0)