VB求运费作业

VB求运费作业,第1张

Private Sub Command1_Click()

Dim W As Integer

Dim M As Double

W = Val(InputBox("请输入重量"))

If W <= 50 Then

M = W 025

ElseIf W > 50 And W <= 100 Then

M = 50 025

M = M + (W - 50) 035

Else

M = 50 025

M = M + 50 035

M = M + (W - 100) 045

End If

Print "价格为" & M

End Sub

加个commmand button 把代码加进去

#include "stdioh"

void main()

{

int flag, weight;

float charge;

prinft("Input weight:");

scanf("%d",&weight);

printf("Input transportation type: (1-air, 2-truck, 3-ship)");

scanf("%d",&flag);

switch (flag)

{

case 1:

if(weight<=20)

charge=100;

else if(weight<=60)

charge=100+30(weight-20)/10;

else

charge=220;

break;

case 2:

if(weight<=30)

charge=50;

else if(weight<=120)

charge=50+15(weight-30)/20;

else

charge=1175;

breack;

case 3:

if(weight<=30)

charge=30;

else if(weight<=80)

charge=30+5(weight-30)/10;

else

charge=55;

}

printf("The charge is %f\n",charge);

}

Private Sub Command1_Click()

a = int(InputBox(""))

if a mod 50 <=0 then

print "你的行李重量是" & a & "Kg,所需运费为" & 15 csng(a)

else

print "你的行李重量是" & a & "Kg,所需运费为" & 15 50 + 25 csng(a mod 50)

End if

End Sub

你的程序里,switch的表达式d是浮点数,但C规定这里。不能是浮点数,只能是整形或其他类型。其实实现很简单,用s去除250这个单位距离就好了,得出的商就是超过的距离数,你看看:

#include<stdioh>

int main()

{

double f,p,w,d,s,y;

printf("3 ge shu\n");

scanf("%lf %lf %lf",&p,&w,&s);

switch((int)s/250)

{

case 0:d=0;break;

case 1:d=002;break;

case 2:d=005;break;

case 4:d=008;break;

case 8:d=01;break;

case 12:d=015;break;

default: d=015;break;

}

f=pws(1-d);

printf("f=%2lf d=%2lf\n",f,d);

}

#include<iostream>

#include<string>

using namespace std;

double fee(double weight)

{

int result=0;

if(weight<50)

result=015weight;

else

result=01550+022(weight-50);

return result;

}

int main()

{

double weight;

cin>>weight;

cout<<"所需总费用为:"<<fee(weight)<<endl;

return 0;

}

以上就是关于VB求运费作业全部的内容,包括:VB求运费作业、2. 两地间货物运费问题:求解C语言 谢谢各位大神、VB火车托运行李运费问题等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/zz/10173206.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-06
下一篇2023-05-06

发表评论

登录后才能评论

评论列表(0条)

    保存