File tree Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Original file line number Diff line number Diff line change 44 * @author PatOnTheBack
55 */
66
7- public class AbsoluteValue {
7+ public class AbsoluteValue {
88
99 public static void main (String [] args ) {
10-
1110 int value = -34 ;
12-
13- System .out .println ("The absolute value of " + value + " is " + abs_val (value ));
14-
11+ System .out .println ("The absolute value of " + value + " is " + absVal (value ));
1512 }
1613
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-
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 ;
2522 }
2623
27- }
24+ }
You can’t perform that action at this time.
0 commit comments