Skip to content

Commit d6fda6f

Browse files
authored
Merge pull request TheAlgorithms#809 from PatOnTheBack/master
Added Maths Folder & Absolute Value Program
2 parents 15f2ebd + b882515 commit d6fda6f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Maths/AbsoluteValue.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package Maths;
2+
3+
/**
4+
* @author PatOnTheBack
5+
*/
6+
7+
public class AbsoluteValue {
8+
9+
public static void main(String[] args) {
10+
int value = -34;
11+
System.out.println("The absolute value of " + value + " is " + absVal(value));
12+
}
13+
14+
/**
15+
* If value is less than zero, make value positive.
16+
*
17+
* @param value a number
18+
* @return the absolute value of a number
19+
*/
20+
public static int absVal(int value) {
21+
return value > 0 ? value : -value;
22+
}
23+
24+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy