package ex03;
public class coin {
public static void main(String[] args) {
final int money = 3890;
int restMoney = money;
int count;
int tempMoney;
int[] coin = { 500, 100, 50, 10 };
for (int i = 0; restMoney != 0; i++) {
tempMoney = coin[i];
for (; restMoney > tempMoney;) {
count = restMoney / tempMoney;
System.out.println(tempMoney + "원 : " + count);
restMoney = restMoney % tempMoney;
}
}
}
}
package ex03;
public class coin {
public static void main(String[] args) {
final int money = 4440;
int restMoney = money;
int count;
int tempMoney;
int[] coin = { 500, 100, 50, 10 };
for (int i = 0; i < 4; i++) {
tempMoney = coin[i];
count = restMoney / tempMoney;
restMoney = restMoney % tempMoney;
System.out.println(tempMoney + "원 : " + count);
}
}
}
package ex03;
import java.util.Scanner;
public class coin {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("입력: ");
final int money = sc.nextInt();
int restMoney = money;
int count;
int tempMoney;
int[] coin = { 500, 100, 50, 10 };
for (int i = 0; i < 4; i++) {
tempMoney = coin[i];
count = restMoney / tempMoney;
restMoney = restMoney % tempMoney;
System.out.println(tempMoney + "원 : " + count);
}
}
}
package ex03;
import java.util.Scanner;
public class coin {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("입력: ");
final int money = sc.nextInt();
int restMoney = money;
int count;
int[] tempMoney = { 500, 100, 50, 10 };
for (int i = 0; i < tempMoney.length; i++) {
count = restMoney / tempMoney[i];
restMoney = restMoney % tempMoney[i];
System.out.println(tempMoney[i] + "원 : " + count);
}
}
}