Merge pull request #809 from PatOnTheBack/master

Added Maths Folder & Absolute Value Program
This commit is contained in:
Yang Libin 2019-08-15 09:12:59 +08:00 committed by GitHub
commit d6fda6f0f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

24
Maths/AbsoluteValue.java Normal file
View File

@ -0,0 +1,24 @@
package Maths;
/**
* @author PatOnTheBack
*/
public class AbsoluteValue {
public static void main(String[] args) {
int value = -34;
System.out.println("The absolute value of " + value + " is " + absVal(value));
}
/**
* If value is less than zero, make value positive.
*
* @param value a number
* @return the absolute value of a number
*/
public static int absVal(int value) {
return value > 0 ? value : -value;
}
}