import java.io.*;
public class Ex3_3_6 {
public static void main (String[] args) throws IOException {
BufferedReader keyin = new BufferedReader(
new InputStreamReader(System.in));
System.out.print("購買金額 (1~999) 元: ");
int buy = Integer.parseInt(keyin.readLine());
int pay=1000, rest;
System.out.println("若支付金額為 " + pay + " 元");
rest = pay-buy;
System.out.println("則應找金額為 " + rest +" 元");
int count=0;
for(int i=rest;i>=100;i-=100){
rest-=100;
count++;
}
System.out.println("找回 100 元張數: " + count);
count=0;
do{
if(rest<10)
break;
rest-=10;
count++;
}while(rest>=10);
System.out.println("找回 10 元數量: " + count);
switch(rest){
case 1:
System.out.println("找回 1 元數量: " + 1);
break;
case 2:
System.out.println("找回 1 元數量: " + 2);
break;
case 3:
System.out.println("找回 1 元數量: " + 3);
break;
case 4:
System.out.println("找回 1 元數量: " + 4);
break;
case 5:
System.out.println("找回 1 元數量: " + 5);
break;
case 6:
System.out.println("找回 1 元數量: " + 6);
break;
case 7:
System.out.println("找回 1 元數量: " + 7);
break;
case 8:
System.out.println("找回 1 元數量: " + 8);
break;
case 9:
System.out.println("找回 1 元數量: " + 9);
break;
case 0:
System.out.println("找回 1 元數量: " + 0);
break;
}
}
}