Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Maths/AbsoluteValue.java
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 " + absVal(value));
}

/**
* If value is less than zero, make value positive.
*
* @param value a number
* @return the absolute value of a number
*/
public static int absVal(int value){
return value > 0 ? value : -value;
}

}