delphi中的case语句实型与字符型怎么相互转换啊?

来源:百度知道 编辑:UC知道 时间:2024/06/26 04:53:49
比如说超市打折:50以下不打折;50-100打九八折;100-200九五折;200以上九折,用case语句怎么写?

为什么不用if语句呢?
用另外一个变量来存放你的字符串表示,单独写个函数。

case
when 金额>200 then 金额*0.9
when 金额>100 and 金额<200 then 金额*0.95
when 金额>50 and 金额<100then 金额*0.98
else 金额
end;

case 金额 of
0..50:
i:=1;
51..100:
i:=0.98;
101..200:
i:=0.95;
else
i:=0.9
end;
折扣后金额:=金额*i;