Skip to content

Comment revisions #1182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Conversions/DecimalToBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* This class converts a Decimal number to a Binary number
*
* @author Unknown
*
*/
class DecimalToBinary {

Expand Down
1 change: 1 addition & 0 deletions Conversions/DecimalToHexaDecimal.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package Conversions;

//hex = [0 - 9] -> [A - F]
class DecimalToHexaDecimal {
private static final int sizeOfIntInHalfBytes = 8;
private static final int numberOfBitsInAHalfByte = 4;
Expand Down
4 changes: 3 additions & 1 deletion Conversions/DecimalToOctal.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
/**
* This class converts Decimal numbers to Octal Numbers
*
* @author Unknown
*
*/
public class DecimalToOctal {
/**
* Main Method
*
* @param args Command line Arguments
*/

//enter in a decimal value to get Octal output
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n, k, d, s = 0, c = 0;
Expand Down
4 changes: 3 additions & 1 deletion Conversions/HexaDecimalToBinary.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package Conversions;

//Hex [0-9],[A-F] -> Binary [0,1]

public class HexaDecimalToBinary {

private final int LONG_BITS = 8;
Expand All @@ -9,7 +11,7 @@ public void convert(String numHex) {
int conHex = Integer.parseInt(numHex, 16);
// Hex a Binary:
String binary = Integer.toBinaryString(conHex);
// Presentation:
// Output:
System.out.println(numHex + " = " + completeDigits(binary));
}

Expand Down
20 changes: 20 additions & 0 deletions Conversions/IntegerToRoman.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
package Conversions;

/**
* Converting Integers into Roman Numerals
*
*('I', 1);
*('IV',4);
*('V', 5);
*('IV',9);
*('X', 10);
*('XL',40;
*('L', 50);
*('XC',90);
*('C', 100);
*('D', 500);
*('M', 1000);
*
*/


public class IntegerToRoman {
private static int[] allArabianRomanNumbers = new int[]{1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
private static String[] allRomanNumbers = new String[]{"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};

//Value must be > 0

public static String integerToRoman(int num) {
if (num <= 0) {
return "";
Expand Down
1 change: 1 addition & 0 deletions Conversions/RomanToInteger.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class RomanToInteger {
put('D', 500);
put('M', 1000);
}};
//Roman Number = Roman Numerals

/**
* This function convert Roman number into Integer
Expand Down
2 changes: 1 addition & 1 deletion Maths/AbsoluteMax.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void main(String[] args) {
}

/**
* get the value, it's absolute value is max
* get the value, return the absolute max value
*
* @param numbers contains elements
* @return the absolute max value
Expand Down
2 changes: 1 addition & 1 deletion Maths/AbsoluteMin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void main(String[] args) {
}

/**
* get the value, it's absolute value is min
* get the value, returns the absolute min value min
*
* @param numbers contains elements
* @return the absolute min value
Expand Down
9 changes: 6 additions & 3 deletions Maths/Factorial.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
package Maths;

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

//Factorial = n! = n1 * (n-1) * (n-2)*...1

/**
* Calculate factorial
* Calculate factorial N
*
* @param n the number
* @return the factorial of {@code n}
*/
public static long factorial(int n) {
if (n < 0) {
throw new ArithmeticException("n < 0");
throw new ArithmeticException("n < 0"); //Dont work with less than 0
}
long fac = 1;
for (int i = 1; i <= n; ++i) {
fac *= i;
}
return fac;
return fac; //Return factorial
}
}
9 changes: 5 additions & 4 deletions Maths/Pow.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package maths;

//POWER (exponentials) Examples (a^b)
public class Pow {
public static void main(String[] args) {
assert pow(2, 0) == Math.pow(2, 0);
assert pow(0, 2) == Math.pow(0, 2);
assert pow(2, 10) == Math.pow(2, 10);
assert pow(10, 2) == Math.pow(10, 2);
assert pow(2, 0) == Math.pow(2, 0); // == 1
assert pow(0, 2) == Math.pow(0, 2); // == 0
assert pow(2, 10) == Math.pow(2, 10); // == 1024
assert pow(10, 2) == Math.pow(10, 2); // == 100
}

/**
Expand Down