diff --git a/Maths/AbsoluteValue.java b/Maths/AbsoluteValue.java new file mode 100644 index 000000000..dfe3915ad --- /dev/null +++ b/Maths/AbsoluteValue.java @@ -0,0 +1,27 @@ +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 " + abs_val(value)); + + } + + public static int abs_val(int value) { + // If value is less than zero, make value positive. + if (value < 0) { + return -value; + } + + return value; + + } + + }