코딩/java

동전계산2

런던전통손만두 2018. 9. 27. 16:22
반응형

import java.util.Scanner;

 

public class Practice_09 {

 

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

 

System.out.print("거스름돈 총액: ");

int total = input.nextInt();

 

int n500 = total / 500;

int n100 = total % 500 / 100;

int n50 = total % 100 / 50;

int n10 = total % 50 / 10;

 

System.out.println("500원짜리 동전: " + n500 + "");

System.out.println("100원짜리 동전: " + n100 + "");

System.out.println("50원짜리 동전: " + n50 + "");

System.out.println("10원짜리 동전: " + n10 + "");

 

input.close();

 

}

 

}

 

결과:

 

 

반응형