商品优惠计算器 使用if语句编程实现输入购货金额,输出实际付款金额。购货折扣率如下: 购货金额≤500元 不打折 500元<购货金额≤1000元 9折 1000元<购货金额 8折
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main()
{
float money=0.0;
float pay=0.0;
bool run = true;
while(run)
{
printf("\n请输入购货金额:\n");
scanf("%f", &money);
if(money >=1000)
{
pay=money*0.8;
printf("打八折,应付金额:%.2f\n",pay);
}
else if((money >500)&&(money <=1000))
{
pay=money*0.9;
printf("打九折,应付金额:%.2f\n",pay);
}
else if(money <=500)
{
printf("不打折,应付金额:%.2f\n",money);
}
}
return 0;
}