Skip to content

Commit

Permalink
[04주차 박상우] 거스름돈
Browse files Browse the repository at this point in the history
  • Loading branch information
pswoo0323 authored Nov 10, 2023
1 parent 21d8455 commit b47feee
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions 04주차/박상우/BOJ5585
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package BAEKJOON;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class BOJ_5585 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

int N = Integer.parseInt(br.readLine());
int paymoney = 1000 - N ;
int[] arr ={500, 100, 50, 10, 5, 1};
int i = 0;
int change = 0;
while (paymoney != 0){
if (paymoney / arr[i] > 0 ){
change = change + paymoney / arr[i]; //1 , 2
paymoney = paymoney % arr[i]; //120 , 20

}
else {
i++;
}
}
System.out.println(change);
}
}

0 comments on commit b47feee

Please sign in to comment.