public static void main(String args[]){
Scanner sc = new Scanner(System.in)
System.out.print("The goods cost:")
int cost=sc.nextInt()
System.out.print("The customer paid:")
int paid=sc.nextInt()
change(cost,paid)
}
public static void change(int cost,int paid){
//unit of cost&paid is dollar
int change=(paid-cost)*100
int numOfTF=0//number of 25 cents
int numOfT=0//number of 10 cents
int numOfF=0//number of 5 cents
if(change<0)//payment is not enough
System.out.println("payment is not enough")
else{
numOfTF=(int)change/25
numOfT=(int)(change-numOfTF*25)/10
numOfF=(int)(change-numOfTF*25-numOfT*10)/5
System.out.println("Change is: "+numOfTF+" 25 cents, "+numOfT+" 10 cents, "+numOfF+" 5 cents.")
}
}
}
X1,X2,X3分别检测到1、5、10元;X4汽水按钮,X5咖啡按钮,X7找零按钮;
Y1汽水灯,Y2咖啡灯,Y3汽水阀,Y4咖啡按阀,Y5找零等,Y6找零阀;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)