Math.round()

ColinSong·2020년 10월 24일
1
post-thumbnail

Math.round()

  • 아래는 변수 num의 값 중에서 백의 자리 이하를 버리는 코드이다.
    만일 변수 num의 값이 '456'이라면 '400'이 돠고, '111'이라면 '100'이 된다.
    알맞은 코드를 작성하시오.

문제

  pubulic class Math_ {
      public static void main(String[] args) {

          int num = 456;
          System.out.print(*1.코드입력*);
          
          int num1 = 111;
          System.out.print(*2. 코드입력*);
      }
  }

결과값
num1 : 400
num2 : 100

코드

  pubulic class Math_ {
      public static void main(String[] args) {

          int num = 456;
          System.out.print("num: " + Math.round((num/100)*100);
          
          int num1 = 100;
          System.out.print("num1 : " + Math.round((num/100)*100);
      }
  }

References

profile
안녕하세요:)

0개의 댓글