[java]代码库
package c;
import java.util.*;
public class n {
public static void main(String[] args){
Scanner out = new Scanner(System.in);
double yuan = 0;
System.out.println("请输入需要找零的金额:");
yuan =out.nextDouble();
double a = 2,b = 1,c = 0.5,d = 0.1 ,e = 0.05,f = 0.02,g = 0.01;
if(yuan > 2){
a =(int) yuan /2;
yuan -= a;
}
else if(yuan > 1){
b =(int) yuan /1;
yuan -= b;
}
else if(yuan > 0.5){
c =(int) yuan /0.5;
yuan -= c;
}
else if(yuan > 0.1){
d =(int) yuan /0.1;
yuan -= d;
}
else if(yuan > 0.05){
e =(int) yuan /0.05;
yuan -= e;
}
else if(yuan > 0.02){
f =(int) yuan /0.02;
yuan -= f;
}
else if(yuan > 0.01){
g =(int) yuan /0.01;
yuan -= g;
}
System.out.println(a);
System.out.println(b);
System.out.println(c*10);
System.out.println(d*10);
System.out.println(e*100);
System.out.println(f*100);
System.out.println(g*100);
}
}