본문 바로가기
(문제풀이)

프로그래머스(java) : 두 수의 나눗셈

by cogito-new 2022. 10. 9.

class Solution {
    public int solution(int num1, int num2) {
        int answer = 0;
        //타입변환 주의
        //들어오는 변수 num1, 2 가 int type
        //나머지 계산시 double 타입 변환 
        double x = (double) num1 / num2;
        answer = (int) (x *1000);
        
        
        return answer;
    }
}

타입변환을 신경써야 하는 문제.

eclipse를 쓰지 않고, 사이트 입력창을 활용하는 연습 진행 중.

반응형