이거 맘대로 되는 세상이 아니구만...

[JAVA]자바 기초 로직 잔돈계산을 시스템창으로 출력하기 본문

java

[JAVA]자바 기초 로직 잔돈계산을 시스템창으로 출력하기

바이홍 2008. 3. 21. 18:14
반응형
class Ja{
    public static void main(String args[]){
        int a=Integer.parseInt(args[0]);
        int b=Integer.parseInt(args[1]);
        int s=a-b;
        int c,d,e,f,g,h;
            c=d=e=f=g=h=0;
        
            c=s/5000;
            h=s%5000;
            d=h/1000;
            h=h%1000;
            e=h/500;
            h=h%500;
            f=h/100;
            h=h%100;
            g=h/50;
            h=h%50;
            h=h/10;
        System.out.println("손님이지불한금액 ="+a);
        System.out.println("손님이 구입한금액 ="+b);
        System.out.println("<<<잔돈내역>>>");
        System.out.println("거스름돈 ="+s);
        System.out.println("오천원="+c+"개");
        System.out.println("천원="+d+"개");
        System.out.println("오백원="+e+"개");
        System.out.println("백원="+f+"개");
        System.out.println("오십원="+g+"개");
        System.out.println("십원="+h+"개");
        
    }
}
반응형
Comments