From 9751ac5e98a10012819d437371b27eed91b54218 Mon Sep 17 00:00:00 2001 From: PatOnTheBack <51241310+PatOnTheBack@users.noreply.github.com> Date: Wed, 7 Aug 2019 21:58:58 -0400 Subject: [PATCH] Added Maths Folder & Absolute Value Program --- Maths/AbsoluteValue.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Maths/AbsoluteValue.java 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; + + } + + }