티스토리 뷰

public class ComputeABS {


public static void main(String[] args) {

// TODO Auto-generated method stub


int value = 5;

System.out.println(value + "'s Absolute Value = " + abs(value));

value = -10;

System.out.println(value + "'s Absolute Value = " + abs(value));

}


static int abs(int value) {

// TODO Auto-generated method stub

if(value < 0)

value *= -1;

return value;

}

}





댓글
댓글쓰기 폼