ITPub博客

首页 > 应用开发 > > 大佬们看下代码错误。。

大佬们看下代码错误。。

作者:hawkliu 时间:2019-07-29 13:40:56 0 删除 编辑

接受用户输入的3种商品的价格。若购买的3种商品中至少有一种商品的价格大于50或者3种商品的总额大于100,则折扣率为95折,否则无折扣率,计算并显示用户应付的钱数。

#include<stdio.h>

int main(void){

float product1,product2,product3=0;

printf("收入三个商品的价格,以空格隔开(输完请按enter): \n");

scanf("%f %f %f", &product1,&product2,&product3);

float total = product1+product2+product3;

if(total>100||(product1>50&&product2>50&&product3>50))

{

total*=0.95;

}

printf("用户应付总价为: %2.2f",total);

    return 0;

}


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/887/viewspace-3166660/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-07-29

  • 博文量
    274
  • 访问量
    1129