运输公司对用户计算运费

来源:互联网 发布:淘宝店铺出售转让风险 编辑:程序博客网 时间:2024/04/30 03:07

s<250km     没有折扣

250<=s<500      2%折扣

500<=s<1000    5%折扣

1000<=s<2000   8%折扣

2000<=s<3000   10%折扣

3000<=s               15%折扣

运费:p货物重量:w距离:s折扣:d总运费:f

f=p*w*s*(1-d)

 *Copyright (c) 2014, 烟台大学计算机学院  * All right reserved.  * 文件名称:test.cpp    * 作者:赵嵩  * 完成时间:2014年12月29号  * 版本号:v1.0  */ #include <iostream>using namespace std;int main(){    double p,w,d,f;    int c,s;    cout<<"please enter p,w,s:";    cin>>p>>w>>s;    if(s>=3000)        c=12;    else        c=s/250;    switch(c)    {    case 0:        d=0;        break;    case 1:        d=2;        break;    case 2:    case 3:        d=5;        break;    case 4:    case 5:    case 6:    case 7:        d=8;        break;    case 8:    case 9:    case 10:    case 11:        d=10;        break;    case 12:        d=15;        break;    }    f=p*w*s*(1-d/100.0);      cout<<"freight="<<f<<endl;    return 0;}

运行结果:


1 0
原创粉丝点击