JAVA/예제

[JAVA] ch05-05. 계산기

밍글링글링 2017. 8. 22.
728x90
 
public class Ex05 { // 계산기.
    public static void main(String[] args){
        Calc calc = new Calc();
        long result1 = calc.add(5L,3L);
        long result2 = calc.substract(5L,3L);
        long result3 = calc.divide(5L,3L);
        double result4 = calc.multiple(5L, 3L);
                
        System.out.printf("%d %d %d %f",result1, result2, result3, result4);
    }
}

class Calc{
    long add(long a, long b){
        long result = a+b;
        return result;
    }
    long substract(long a, long b){
        return a-b;
    }
    long multiple(long a, long b){
        return a*b;
    }
    long divide(long a, long b){
        return a/b;
    }
}

728x90

댓글