回 帖 发 新 帖 刷新版面

主题:求助~!!!!!

题目:
某运输公司的运费标准如下:
1、当运输距离s>300公里时:
   货重w<2吨时,按98%收费;
   2<w<4时,按96%收费;
   4<w<6时,按94%收费;
   w>6时,按92%收费。
2、当运输距离s<300公里时:
   w<2时,按100%收费;
   2<w<4时,按98%收费;
   4<w<6时,按96%收费;
   w>6时,按94%收费。
在写程序前,设P为每公里运费,cost为向用户收取的费用。
程序如下:
program carriage(input,output);
var
   s300:boolean;
   p,w,s,cpst:real;
begin
   write('please input p,w,s:');
   readln(p,s,w);
   cost:=p*w*e;
   s300:=  s>=300;
   If s300 and (w<=2) then
       cost:=cost*0.98;
   If s300 and (w>=2) and (w<4) then
       cost:=cost*0.96;
   If s300 and (w>=4) and (w<6) then
       cost:=cost*0.94;
   If s300 and (w>=6) then
       cost:=cost*0.92;
   If not s300 and (w>=2) and (w<4) then
       cost:=cost*0.98;
   If not s300 and (w>=4) and (w<6) then
       cost:=cost*0.96;
   If not s300 and (w>=6) then
       cost:=cost*0.94;
   writeln('price=',p:6:2,    'wight=',w:6:2,   'distance=',s:6:2);
   writeln('cost=',cost:6:2)
end.

请各位GGJJDDMM们,看看这个程序哪里出错了,怎么不可以运行?

回复列表 (共4个回复)

沙发

program carriage(input,output);
var s300:boolean;
    p,w,s,cost:real;
begin
   write('please input p,w,s:');
   readln(p,w,s);
   cost:=p*w*s;
   s300:=  s>=300;
   If s300 and (w<=2) then
       cost:=cost*0.98;
   If s300 and (w>=2) and (w<4) then
       cost:=cost*0.96;
   If s300 and (w>=4) and (w<6) then
       cost:=cost*0.94;
   If s300 and (w>=6) then
       cost:=cost*0.92;
   If not s300 and (w>=2) and (w<4) then
       cost:=cost*0.98;
   If not s300 and (w>=4) and (w<6) then
       cost:=cost*0.96;
   If not s300 and (w>=6) then
       cost:=cost*0.94;
   writeln('price=',p:6:2);
   writeln('wight=',w:6:2);
   writeln('distance=',s:6:2);
   writeln('cost=',cost:6:2);
end.

板凳

program carriage(input,output);
var s300:boolean;
    p,w,s,cost:real;
begin
   write('please input p,w,s:');
   readln(p,w,s);
   cost:=p*w*s;
   s300:=  s>=300;
   If s300 and (w<=2) then
       cost:=cost*0.98;
   If s300 and (w>=2) and (w<4) then
       cost:=cost*0.96;
   If s300 and (w>=4) and (w<6) then
       cost:=cost*0.94;
   If s300 and (w>=6) then
       cost:=cost*0.92;
   If not s300 and (w>=2) and (w<4) then
       cost:=cost*0.98;
   If not s300 and (w>=4) and (w<6) then
       cost:=cost*0.96;
   If not s300 and (w>=6) then
       cost:=cost*0.94;
   writeln('price=',p:6:2);
   writeln('wight=',w:6:2);
   writeln('distance=',s:6:2);
   writeln('cost=',cost:6:2);
end.

3 楼

[font=宋体]我试过可以运行,不知答案对不对。[/font]

4 楼

哦,那谢谢啦~

我来回复

您尚未登录,请登录后再回复。点此登录或注册