找零计算器
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
double nPrice, nPay, nReturn;
printf("请输入该件商品的价格\n");
scanf("%lf", &nPrice);
while (nPrice<0)
{
printf("输入错误,请输入该件商品的价格\n");
scanf("%lf", &nPrice);
}
printf("请输入用户支付的钱数\n");
scanf("%lf", &nPay);
while (nPay<nPrice)
{
printf("输入错误,请输入用户支付的钱数\n");
scanf("%lf", &nPay);
}
nReturn = nPay - nPrice;
printf("找零%lf\n", nReturn);
system("pause");
return 0;
}