Skip to content

Commit 9751ac5

Browse files
committed
Added Maths Folder & Absolute Value Program
1 parent 15f2ebd commit 9751ac5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Maths/AbsoluteValue.java

+27
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)