We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 15f2ebd commit 9751ac5Copy full SHA for 9751ac5
Maths/AbsoluteValue.java
@@ -0,0 +1,27 @@
1
+package Maths;
2
+
3
+/**
4
+ * @author PatOnTheBack
5
+ */
6
7
+ public class AbsoluteValue {
8
9
+ public static void main(String[] args) {
10
11
+ int value = -34;
12
13
+ System.out.println("The absolute value of " + value + " is " + abs_val(value));
14
15
+ }
16
17
+ public static int abs_val(int value) {
18
+ // If value is less than zero, make value positive.
19
+ if (value < 0) {
20
+ return -value;
21
22
23
+ return value;
24
25
26
27
0 commit comments